Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00022
00023
00024 #include <cppunit/TextOutputter.h>
00025 #include <cppunit/CompilerOutputter.h>
00026 #include <cppunit/XmlOutputter.h>
00027 #include <cppunit/TestResult.h>
00028 #include <cppunit/TestResultCollector.h>
00029 #include <cppunit/TestRunner.h>
00030 #include <cppunit/extensions/TestFactoryRegistry.h>
00031
00032 #include <icl_core/os_lxrt.h>
00033 #include <icl_core_logging/Logging.h>
00034
00035 #include "icl_core_testsuite/TestListener.h"
00036 #include "icl_core_testsuite/test_suite.h"
00037
00038 namespace icl_core {
00039
00040 int runCppunitTestSuite(TestResultOutputType outputType)
00041 {
00042 icl_core::os::lxrtStartup();
00043 icl_core::logging::initialize();
00044
00045
00046 CPPUNIT_NS::TestResult testresult;
00047
00048
00049 CPPUNIT_NS::TestResultCollector collectedresults;
00050 testresult.addListener(&collectedresults);
00051
00052
00053 CPPUNIT_NS::TestRunner testrunner;
00054 testrunner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
00055
00056
00057 switch (outputType)
00058 {
00059 case eTROT_Text:
00060 {
00061 icl_core::TestListener progress;
00062 testresult.addListener(&progress);
00063
00064 testrunner.run(testresult);
00065
00066 CPPUNIT_NS::TextOutputter textoutputter(&collectedresults, std::cerr);
00067 textoutputter.write();
00068 break;
00069 }
00070 case eTROT_Compiler:
00071 {
00072 icl_core::TestListener progress;
00073 testresult.addListener(&progress);
00074
00075 testrunner.run(testresult);
00076
00077 CPPUNIT_NS::CompilerOutputter compileroutputter(&collectedresults, std::cerr);
00078 compileroutputter.write();
00079 break;
00080 }
00081 case eTROT_Xml:
00082 {
00083 testrunner.run(testresult);
00084
00085 CPPUNIT_NS::XmlOutputter xmloutputter(&collectedresults, std::cerr, "UTF-8");
00086 xmloutputter.write();
00087 break;
00088 }
00089 }
00090
00091 icl_core::logging::shutdown();
00092 icl_core::os::lxrtShutdown();
00093
00094
00095 return collectedresults.wasSuccessful() ? 0 : 1;
00096 }
00097
00099 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00100
00101 int RunCppunitTestSuite(TestResultOutputType outputType)
00102 {
00103 return runCppunitTestSuite(outputType);
00104 }
00105
00106 #endif
00107
00108
00109 }