Every test in a group's collection is owned by the group. That means when a group is destroyed, every test in the group's collection is also destroyed.
Creating an unordered group of tests
Derive from TTestSet when you need to create a group of tests in which the order you perform the tests does not matter. In addition, you can have the Test framework randomly reorder the tests each time you perform the tests.
To create a randomly ordered set of tests:
1 void TSampleObjectTestSet::SetupSubtests() 2 { 3 TAllocationHeap heap(this); 4 AdoptTest(new(heap) TSampleObjectSimpleTest); 5 AdoptTest(new(heap) TSampleObjectFailTest); 6 AdoptTest(new(heap) TSampleObjectBaseTest); 7 } 8 9 void TSampleObjectTestSet::Setup() 10 { 11 TTestSet::Setup(); 12 RandomlyReorder(); 13 }
Line number 11 calls the base class Setup function to select the tests specified in the SetupSubtests member function.
Line number 12 uses the RandomlyReorder function to force the set of tests to perform randomly each time you call the test class.
Creating an ordered
list of tests
Use a derived class of TTestSequence when you have a group of related tests that must be executed in a fixed order. The default behavior is to halt when any subtest fails.
To create an ordered set of tests:
void TSampleObjectTestSequence::SetupSubtests() { TAllocationHeap heap(this); AdoptFirstTest(new(heap) TSampleObjectSimpleTest); AdoptLastTest(new(heap) TSampleObjectBaseTest); }