[Cppunit-devel] order of construction, setUp, tearDown and destruction?
Brought to you by:
blep
From: Graham, T. <Ted...@cs...> - 2001-10-24 23:50:41
|
We are in the process of adopting cppUnit as our automated test framework for a large suite of business objects. Our objects are reference counted, so I want to check of how many object are in memory before and after each test to make sure that neither the tests nor the code being tested are leaking references. My understanding of a test cases's lifecycle used to be (from a doc I wrote): for( testClass = testClass1...testClass99 ) // every test class for( test = test1...test99 ) // every test in that test class testClass thisTest; // e.g., CustomerTest thisTest testClass.setUp(); // virtual function, can be overriden by testClass thisTest.test() testClass.tearDown(); // clean up anything that was built in setUp delete testClass; // the test class is destroyed after each test. From debugging the framework, this doesn't seem to be the case. Instantiation happens earlier, and tearDown and destruction are delayed until after all tests have run. I have a object BaseTest that inherits from CppUnit::TestCase and is the superclass to all our tests. Imagine I have a function getTotalObjects() that returns how many reference counted objects are in memory. I'd like to call this in setUp and again in tearDown and verify that it hasn't changed while the test was being run. But I need to know what the lifecycle of test class is, and when setUp and tearDown are called. Any help?? Thanks, Ted |