w6 - CSC209: Unit Testing, Structs and Files Kante Easley...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSC209: Unit Testing, Structs and Files Kante Easley University of Toronto June 17, 2009 Kante Easley CSC209 CSC209: Running your tests In todays tutorial we talked about how to pick a good set of test cases. One way to run your tests is to manally create testing code. Time consuming Could be error prone Reinventing the wheel There are many unit testing packages available that make the process of testing your functions easier. Kante Easley CSC209 CSC209: CuTest I did a Google search for c unit testing The first result was for CuTest. lightweight :) (only 2 source files to include) easy to use :) free :) memory errors cause the testing program to crash :( ??? Do your own google search to find a unit testing program that works for you We will stick with CuTest for todays examples Kante Easley CSC209 CSC209: CuTest includes You will need to include the following in your test code: #include <assert.h> #include <setjmp.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "CuTest.h" Note the format of the last include. This is for including header files in your current working directory. See todays files for chop_out.c and chop_out.h Kante Easley CSC209 CSC209: CuTest Test Cases For each test you want to create, you will need to write a function Make the name meaningful - should have something to do with what is being tested You will use the assertions declared in CuTest.h to assert the things that must be true in order for your test to pass For example void test_adding(CuTest* tc) { CuAssertIntEquals(tc, 1 + 1, 2); } void test_boolean{ int the_sky_is_blue = 1; CuAssertTrue(tc, the_sky_is_blue); } Kante Easley CSC209 CSC209: CuTest Test Suites You will organize your test cases by adding them into collections called test suites....
View Full Document

This note was uploaded on 04/10/2010 for the course CSC CSC209 taught by Professor Kante during the Spring '10 term at University of Toronto- Toronto.

Page1 / 20

w6 - CSC209: Unit Testing, Structs and Files Kante Easley...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online