Re: How to check the test result in the tearDown()
"Baptiste Lepilleur" <blepi-fBIn7JHAfCbUKx/[email protected]> Thu, 23 Jan 2003 23:52:20 +0100
| Newsgroups | gmane.comp.lib.cppunit.devel |
|---|---|
| Message-ID | <002401c2c332$175765e0$3cd92cd5@lain> |
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" <eugene.zozulya-/azQCtZra8xWk0Htik3J/[email protected]> To: <[email protected]> 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 [email protected] https://lists.sourceforge.net/lists/listinfo/cppunit-devel ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com