I want to set up multiple tests in a suite ('hosted' in a class). I set up something like this:
class CTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST_SUITE( CTest );
CPPUNIT_TEST( testLogon );
CPPUNIT_TEST( testVol );
The problem is that I want to create/use a single database connection (in a member variable) that is common to all tests. I tried to create a CTest constructor and destructor, but it appears that for every test I get setUp/tearDown AND the CTest constructor/destructor executed. And getting rid of the constructor/destructor still means the setUp/tearDown run on every test...
This means that my database connection gets created and gets dropped on every test. Is this by design? I don't want to group multiple test cases under one suite test because this results in always a 100% success or a 100% failure of the suite.
Any guidance would be appreciated as this is my first use of CPPUnit.
Thanks in Advance!
In my opinion u should not use a TestFixture, use a TestCase for every test u want, and group them in a CppUnit::TestSuite.
-create your database connection object
-create your class of test : MyClass:public CppUnit::TestCase;
-u pass the connection object and test parameters on the constructor of MyClass ...
-u can create many test as u want with different parameters, then group them in a CppUnit::TestSuite
-finally u run all tests
-after tests finished u close the database connection
Sorry for my bad english, hope it will help u.
Log in to post a comment.