class MyTest : public CppUnit::TestCase {
private:
public:
void setUp () {}
void tearDown () {}
void testOne () {}
void testTwo () {}
};
int
main()
{
CppUnit::TestSuite suite;
CppUnit::TestResult result;
suite.addTest (new CppUnit::TestCaller<MyTest>("testOne", &MyTest::testOne));
suite.addTest (new CppUnit::TestCaller<MyTest>("testTwo", &MyTest::testTwo));
CppUnit::TextTestRunner runner;
// commneting out the next line and
// uncommenting the following two makes
// the problem go away.
runner.addTest (&suite);
//runner.addTest (new CppUnit::TestCaller<MyTest>("testOne", &MyTest::testOne));
//runner.addTest (new CppUnit::TestCaller<MyTest>("testTwo", &MyTest::testTwo));
runner.run ();
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2002-03-14
The example I posted seems to work for me now.
I will try again to reproduce the problem.
Sorry.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I add a TestSuite to a TextTestRunner, I get s seg fault after the tests run. This does not happen if I add TestCallers instead.
Am I doing something wrong here?
I am running Mandrake Linux 8.1
gcc version 2.96 20000731
-----------------------------------
#include <cppunit/TestCase.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
#include <cppunit/TestResult.h>
#include <cppunit/TextTestRunner.h>
#include <ostream.h>
class MyTest : public CppUnit::TestCase {
private:
public:
void setUp () {}
void tearDown () {}
void testOne () {}
void testTwo () {}
};
int
main()
{
CppUnit::TestSuite suite;
CppUnit::TestResult result;
suite.addTest (new CppUnit::TestCaller<MyTest>("testOne", &MyTest::testOne));
suite.addTest (new CppUnit::TestCaller<MyTest>("testTwo", &MyTest::testTwo));
CppUnit::TextTestRunner runner;
// commneting out the next line and
// uncommenting the following two makes
// the problem go away.
runner.addTest (&suite);
//runner.addTest (new CppUnit::TestCaller<MyTest>("testOne", &MyTest::testOne));
//runner.addTest (new CppUnit::TestCaller<MyTest>("testTwo", &MyTest::testTwo));
runner.run ();
}
The example I posted seems to work for me now.
I will try again to reproduce the problem.
Sorry.
From the doc:
- The test runner manage the life cycle of the added tests.
=> that means after running the test, the test runner will delete the suite.
You must instantiate your suite with new TestSuite().
Baptiste.