Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does cppUnit use fork() when it launch each unit test?

I'm using cppunit for the unit tests of my project.

And I m wondering if the cppunit launch each unit test in a new fork() system call because:

  • Using fork will allow to create a new address space in which to run each unit test
  • Using fork will allow to keep the unit tests running even if one of them causes a crash.

I defined a global variable and then I tried to change the global variable in the unit test and change that has no affect in the parent process but unfortunally I found that global variable is changed.

So by default cppunit does not support launching unit test with fork(). And I m wondering if there is macros in cppunit that could initiate unit test with fork() ?

My tests are defined in the following way:

class MYTest : public CppUnit::TestCase {

   CPPUNIT_TEST_SUITE( MYTest );
   CPPUNIT_TEST( getRetryValueTest );
   CPPUNIT_TEST( getRetryValueTest2 );
   CPPUNIT_TEST_SUITE_END(); 

   public:
      virtual void setUp();

      void getRetryValueTest();
      void getRetryValueTest2();
};
like image 534
MOHAMED Avatar asked Nov 29 '25 12:11

MOHAMED


1 Answers

Cppunit does not use fork to separate tests. However tests in the same suite are separate objects so each test has its own set of variables and are therefore independent from each other and can't influence each other.

like image 189
moggi Avatar answered Dec 01 '25 00:12

moggi