Is the CppUnit Thread safe? Can I open a thread from a class derived from TestFixture and in one of it's test cases open a thread and in this thread use the CPPUNIT_ASSERT(expression);?
myClass :public TestFixture { public: void testXXX();
CPPUNIT_TEST_SUITE( myClass ); CPPUNIT_TEST( testXXX); CPPUNIT_TEST_SUITE_END();
private: Thread _t; }
void myClass::testXXX() { //Here I open a thread that will use expessions //like CPPUNIT_ASSERT(expression);? //is this OK? _t.start(); }
Assertion are thread-safe. They don't use any stati c variables and just throw an exception in case of failure.
If you spawn a thread, be sure to catch the exception and propagate it in the main thread (you can clone it using clone() ).
Baptiste.
Log in to post a comment.
Is the CppUnit Thread safe?
Can I open a thread from a class derived from TestFixture and in one of it's test cases open a thread and in this thread use the CPPUNIT_ASSERT(expression);?
myClass :public TestFixture {
public:
void testXXX();
CPPUNIT_TEST_SUITE( myClass );
CPPUNIT_TEST( testXXX);
CPPUNIT_TEST_SUITE_END();
private:
Thread _t;
}
void myClass::testXXX()
{
//Here I open a thread that will use expessions
//like CPPUNIT_ASSERT(expression);?
//is this OK?
_t.start();
}
Assertion are thread-safe. They don't use any stati c variables and just throw an exception in case of failure.
If you spawn a thread, be sure to catch the exception and propagate it in the main thread (you can clone it using clone() ).
Baptiste.