CPPUNIT TUTORIAL PDF

Click here for a larger image. Within a Quality Assurance process, we have mainly two kinds of tests:. I'm going to consider that you know what unit testing is, and why it is very important in the software development process. If you want to read more about the unit testing basis, you can check the JUnit Web site.

Author:Zuluktilar Dikasa
Country:Cyprus
Language:English (Spanish)
Genre:Relationship
Published (Last):26 November 2011
Pages:484
PDF File Size:14.21 Mb
ePub File Size:2.19 Mb
ISBN:675-3-83827-285-6
Downloads:76733
Price:Free* [*Free Regsitration Required]
Uploader:Samugar



Assuming that you want to test a class called Parser. The following are the general steps to use the CppUnit framework to test this class: Write a class let's call it TestParser to test the Parser class.

A test fixture is a set of sample objects that you want to re use during testing. For example, you might create a few sample source files for the Parser to parse. CppUnit provides a setUp and a tearDown method to manage the fixture.

Therefore, you can create file objects in setUp to open the source files and release these resources in the tearDown method. The important thing to note is that setUp and tearDown will be called for every 'test' that you run.

Each 'test' you perform is represented by the implementation of a method in the test class. For example, if you want to test whether the parser extracts the tokens correctly, you can implement a method called testGetToken. The collection of test methods you implement forms a test suite. In each test method you create, use the assertion mechanism provided by CppUnit to compare the results of running the test and the expected results.

This will enable you to create repeatable tests as well as saving you lots of time from visually inspecting the results. Finally, use the textual version of the TestRunner tool to run the tests and collect the results. As each test is run, CppUnit will provide feedback on whether the test ran successfully, or the test failed, or an exception has occurred.

Example In this section, we will describe how you can use CppUnit using an example the reference section provides the link to download the sample files used for this guide. Take a few minutes to examine the following two classes. Each Course contains a name eg. CS and an integer grade which ranges from 0 to Each Student has a name, a number as well as a list of course grades. You can add the grade that a student scores at a particular course using the assignGrade method and retrieve the grade of a particular course using the getGrade method.

Next, create the test class. The following are the test files we wrote for the Student class called TestStudent. Modify default project settings, add references to include CppUnit library and header files and include a post-build unit testing command by setting the following from the menu bar:. Run unit testing by building the project press F6. The results of the unit tests will be displayed in the output tab add the bottom of the Visual Studio IDE. Alternatively, simply run the program by pressing F5.

DVE 5207 PDF

Crash Course in using CppUnit

.

LISU BIBLE PDF

CppUnit: C++ unit test framework

.

MAD MONKS OF KWANTOOM PDF

Unit Testing with CPPUnit

.

Related Articles