Salome HOME
First publish of HEXABLOCKcomponant
[modules/hexablock.git] / src / TEST_CPP / Test_HEXABLOCK.cxx
1 #include <cppunit/BriefTestProgressListener.h>
2 #include <cppunit/CompilerOutputter.h>
3 #include <cppunit/extensions/TestFactoryRegistry.h>
4 #include <cppunit/TestResult.h>
5 #include <cppunit/TestResultCollector.h>
6 #include <cppunit/TestRunner.h>
7 #include <cppunit/XmlOutputter.h>
8
9 int main(int argc, char* argv[])
10 {
11         // Retrieve test path from command line first argument. Default to "" which resolve
12         // to the top level suite.
13         std::string testPath = (argc > 1) ? std::string(argv[1]) : std::string("");
14         
15         // Create the event manager and test controller
16         CPPUNIT_NS::TestResult controller;
17         
18         // Add a listener that collects test result
19         CPPUNIT_NS::TestResultCollector result;
20         
21         controller.addListener( &result );
22         
23         // Add a listener that print dots as test run.
24         CPPUNIT_NS::BriefTestProgressListener progress;
25         
26         controller.addListener( &progress );
27         
28         // Add the top suite to the test runner
29         CPPUNIT_NS::TestRunner runner;
30         runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
31         runner.run( controller );
32         
33         // Print test in a compiler compatible format.
34         CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
35         outputter.write();
36         
37         // Uncomment this for XML output
38         std::ofstream file( "cppunit-report.xml" );
39         
40         CPPUNIT_NS::XmlOutputter xml( &result, file );
41         
42         xml.write();
43         
44         file.close();
45         
46         return result.wasSuccessful() ? 0 : 1;
47 }