CODE: //--- Hello, World! for CppUnit #include #include #include #include #include #include #include class MyTest : public CppUnit::TestCase { CPPUNIT_TEST_SUITE(MyTest); CPPUNIT_TEST(testHelloWorld); CPPUNIT_TEST_SUITE_END(); public: void setUp(void) {} void tearDown(void) {} protected: void testHelloWorld(void) { std::cout <<"Hello, world!" < CPPUNIT_TEST_SUITE_REGISTRATION(MyTest); int main( int ac, char **av ) { //--- Create the event manager and test controller CppUnit::TestResult controller; //--- Add a listener that colllects test result CppUnit::TestResultCollector result; controller.addListener( &result ); //--- Add a listener that print dots as test run. CppUnit::BriefTestProgressListener progress; controller.addListener( &progress ); //--- Add the top suite to the test runner CppUnit::TestRunner runner; runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); runner.run( controller ); return result.wasSuccessful() ? 0 : 1; } 写下你的评论吧 !
推荐阅读
|