Hi, I want to show, how I successfull run the simple unit test and where I found some bug.
I have this TestCase class:
- Code: Select all
class CPositionTest : public TestCase {
public:
CPositionTest (string name) : TestCase(name) { }
void testOperators ();
static Test* suite () {
TestSuite *suite = new TestSuite;
TestCaller<CPositionTest> *cal = new TestCaller<CPositionTest> ("testOperators", &CPositionTest::testOperators);
suite->addTest (cal);
return suite;
}
};
There is a problem in the TestCase.h and TestCaller.h files in some pseudodocumentation there..
- Code: Select all
suite->addTest (new TestCaller<MathTest> ("testAdd", testAdd));
will not work, it will produce an error on compilation:
src/tests/CPositionTest.h: In static member function `static CppUnit::Test* CPositionTest::suite()':
src/tests/CPositionTest.h:28: error: no matching function for call to `CppUnit::TestCaller<CPositionTest>::TestCaller(const char[14], <unknown type>)'
include/CppUnit/TestCaller.h:59: note: candidates are: CppUnit::TestCaller<Fixture>::TestCaller(const std::string&, void (Fixture::*)()) [with Fixture = CPositionTest]
include/CppUnit/TestCaller.h:54: note: CppUnit::TestCaller<Fixture>::TestCaller(const CppUnit::TestCaller<Fixture>&) [with Fixture = CPositionTest]
mingw32-make: *** [obj/CPositionTest.o] Error 1
There in my example it's rewritten and it works:
new TestCaller<CPositionTest> ("testOperators",
&CPositionTest::testOperators);
The string "testOperators" must not match the name of the class method.
Please, is this the right way to use the test cases

Can you discus your experiences here?