[Cppunit-devel] fixture between different test methods?
Brought to you by:
blep
From: CppUnit d. m. l. <cpp...@li...> - 2007-02-12 18:33:16
|
Hi cppunit developers and users! I have a question about test execution. I have a test suit as shown below with two test methods. The code is then compiled into a dll and I run it with this command: DllPlugInTesterd_dll.exe -c plugin_d.dll I now have the following problem. During startup cppunit creates two instances of the ExampleTest class. Then it calls setup(), sampleTest() and finally teardown(). Then it does the same on the second instance with the method sampleTest2(). This looks quite strange. I thought I could initialize some class in the setup method which is then shared between all the different test method calls? The reason why I would like to share an instance between them is that I have to start an external program during test execution (which takes very long and therefore should not be started and killed for each test method invocation). I therefore used a shared pointer which I thought would be accessible for all test invocations. But since each invocation uses a different instance this does not work. Any suggestions how this should be done would be really great! Please also tell me if what I wrote / want is unclear Thanks a lot, Fabian class ExampleTest : public CPPUNIT_NS::TestFixture { CPPUNIT_TEST_SUITE( ExampleTest ); CPPUNIT_TEST( sampleTest ); CPPUNIT_TEST( sampleTest2 ); CPPUNIT_TEST_SUITE_END(); public: void setUp(); void tearDown(); // The different test methods void sampleTest(); void sampleTest2(); }; |