Driver file to create and execute the test suite.
More...
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
Go to the source code of this file.
|
int | main (int argc, char *argv[]) |
|
Driver file to create and execute the test suite.
Brief instruction on how to set CppUnit: from: http ://www.comp.nus.edu.sg/~cs3215/tools/cppunitAll.html
First, to install cppUnit :
- Unpack the CppUnit archive file to a directory of your choice, in this example I assume it is D:.
- Go to D:/cppunit-1.12.1/src and open the CppUnitLibraries.sln in Visual Studio.
- Right - click on the cppunit project in the Solution Explorer pane and choose Build.
- After successful compilation, cppunit.lib is produced which you then need to setup the Visual Studio Linker with (see below).
To setup a project from scratch for Compilation / Linking:
- Activate 'Project > Properties > C/C++ > Code Generation > Runtime Library > Multi - threaded Debug DLL'
- Go to 'Project > Properties > C/C++ > General'. Put "D:\cppunit-1.12.1\include" in the 'Additional Include Directories' text box.
- Go to 'Project > Properties > Linker > Input'. Put "D:\cppunit-1.12.1\lib\cppunit.lib" in the 'Additional Dependences' text box.
- Go to 'Project > Properties > Build Events > Post-Build Event'. Put '"$(TargetPath)"' in the 'Command Line' textbox.Put 'Unit Tests...' in the 'Description' textbox.
Definition in file RunApp.cpp.
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
main() function. Entry point of the program It does the following:
- Create a test suite object from the registry as populated by the code in the Test Classes
- Create a test runner that will execute all the tests in the registry
- (optionally) sets an outputter that will output the results
- Run the test cases.
Definition at line 31 of file RunApp.cpp.
34 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
37 CppUnit::TextUi::TestRunner runner;
38 runner.addTest( suite );
41 runner.setOutputter(
new CppUnit::CompilerOutputter( &runner.result(),
44 bool wasSucessful = runner.run();
49 return wasSucessful ? 0 : 1;