Commit c60d2b94 authored by rakshasa's avatar rakshasa

Updated cppunit test setup.

parent 99e33c00
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
int main(int argc, char* argv[])
{
CppUnit::TestResult controller;
CppUnit::TestResultCollector result;
CppUnit::BriefTestProgressListener progressListener;
controller.addListener( &result );
controller.addListener( &progressListener );
// Get the top level suite from the registry
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
......@@ -15,9 +24,22 @@ int main(int argc, char* argv[])
// Change the default outputter to a compiler error format outputter
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
std::cerr ) );
// Run the tests.
bool wasSucessful = runner.run();
try {
std::cout << "Running ";
runner.run( controller );
std::cerr << std::endl;
// Print test in a compiler compatible format.
CppUnit::CompilerOutputter outputter( &result, std::cerr );
outputter.write();
} catch ( std::invalid_argument &e ) { // Test path not resolved
std::cerr << std::endl
<< "ERROR: " << e.what()
<< std::endl;
return 1;
}
// Return error code 1 if the one of test failed.
return wasSucessful ? 0 : 1;
return result.wasSuccessful() ? 0 : 1;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment