Re: [Cppunit-devel] How to check the test result in the tearDown()
Brought to you by:
blep
From: Baptiste L. <bl...@cl...> - 2003-01-23 22:50:27
|
There is no clean way to do that. Are you sure that what you're trying to do could not be achieved using a TestListener ? The code below does not work because the instance of the TestResult being used is not the one used to run the test. Baptiste. ----- Original Message ----- From: "Eugene Zozulya" <eug...@th...> To: <cpp...@li...> Sent: Friday, January 10, 2003 4:01 PM Subject: [Cppunit-devel] How to check the test result in the tearDown() Hi all, Is any way to know the test result in the tearDown() except using the flags? The following doesn't work (might be stupid, but I've tried...): // cppunit-1.9.10 class MyTest: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( MyTest ); CPPUNIT_TEST( MyTestCase ); CPPUNIT_TEST_SUITE_END(); public: virtual void setUp(); virtual void tearDown(); void MyTestCase(); private: fstream m_OutFile; CPPUNIT_NS::TestResultCollector *m_pResult; } CategMapTest::MyTest() { m_OutFile.open("MyTest.out", ios::out | ios::app); m_pResult = new CPPUNIT_NS::TestResultCollector(); CPPUNIT_NS::TestResult().addListener( m_pResult ); } CategMapTest::~MyTest() { m_OutFile.close(); delete m_pResult; } void MyTest::setUp() { } void MyTest::MyTestCase() { CPPUNIT_ASSERT(false); } void MyTest::tearDown() { static int l_count=0; m_OutFile << " test " << ++l_count << " - " << m_pResult->wasSuccessful() << " - " << m_pResult->runTests() << " - " << m_pResult->testErrors() << " - " << m_pResult->testFailures() << " - " << m_pResult->testFailuresTotal() << endl; } Any suggestions would be appreciated. Thanks, Eugene ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld =omething 2 See! http://www.vasoftware.com _______________________________________________ Cppunit-devel mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppunit-devel |