Generic test runner.The TestRunner assumes ownership of all added tests: you can not add test or suite that are local variable since they can't be deleted.
More...
#include <TestRunner.h>
List of all members.
Detailed Description
Generic test runner.
The TestRunner assumes ownership of all added tests: you can not add test or suite that are local variable since they can't be deleted.
Example of usage:
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/TextTestProgressListener.h>
int
main( int argc, char* argv[] )
{
std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
CppUnit::TestResult controller;
CppUnit::TestResultCollector result;
controller.addListener( &result );
CppUnit::TextTestProgressListener progress;
controller.addListener( &progress );
CppUnit::TestRunner runner;
runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );
try
{
std::cout << "Running " << testPath;
runner.run( controller, testPath );
std::cerr << std::endl;
CppUnit::CompilerOutputter outputter( &result, std::cerr );
outputter.write();
}
catch ( std::invalid_argument &e )
{
std::cerr << std::endl
<< "ERROR: " << e.what()
<< std::endl;
return 0;
}
return result.wasSuccessful() ? 0 : 1;
}
Constructor & Destructor Documentation
TestRunner::TestRunner |
( |
| ) |
|
TestRunner::~TestRunner |
( |
| ) |
[virtual] |
TestRunner::TestRunner |
( |
const TestRunner & |
copy | ) |
[private] |
Prevents the use of the copy constructor.
Member Function Documentation
void TestRunner::addTest |
( |
Test * |
test | ) |
[virtual] |
Adds the specified test.
- Parameters:
-
void TestRunner::operator= |
( |
const TestRunner & |
copy | ) |
[private] |
Prevents the use of the copy operator.
void TestRunner::run |
( |
TestResult & |
controller, |
|
|
const std::string & |
testPath = "" |
|
) |
| [virtual] |
Runs a test using the specified controller.
- Parameters:
-
- Exceptions:
-
Member Data Documentation
The documentation for this class was generated from the following files: