-
class
TestSuite
: Test
-
Base implementation for test suites.
This class forms the basic skeleton for test suites. It could be used as base
class for real test suite implementations. A test suite is
a set of unit tests (instances which implement the Test interface) that
should be executed altogether. Normally this is the case when all members
of a suite test functionality in the same (sub)domain. A test suite could
contain test cases and other test suites. This allows to structure
unit tests in a hierarchical, file-system like manner.
Public Members:
-
TestSuite (const string& name, bool breakOnFailure = false) ;
-
Create a test suite.
Sets the suites name. If breakOnFailure is true, the suite
stops executing the remaining tests if a test fails. Otherwise, always
all tests are executed.
-
virtual ~TestSuite () ;
-
The destructor.
Also all contained tests are deleted.
-
virtual bool run (TestConductor&) ;
-
Make the conductor run the test suite.
Executing the test suite and returning the success state is
delegated to the conductor.
-
virtual void setUp () ;
-
Set up the test suite
Dummy implementation with no functionality.
If all members of the test suite need the same test environment
which need not to be restored before each test, the installation
of the shared test environment could be done in this method.
-
virtual void test (TestConductor&) ;
-
Run the tests in the suite
All members of the test suite are run under the control
of the given test conductor.
-
virtual void tearDown () ;
-
Tear down the test environment of the suite.
Dummy implementation with no functionality.
-
virtual bool isTestCase () const ;
-
Test if the suite is a test case.
Always returns false.
-
virtual int noTestCases () const ;
-
Count the number of test cases
Computes the number of test cases in the suite and all
contained sub-suites.
-
virtual int noTestSuites () const ;
-
Counts the number of test suites in the suite
Returns the number of (directly or indirectly) contained
test suites plus one.
-
virtual void put (ostream& stream) const ;
-
Output the test suite to the stream.
The string "Test suite: " and the name is printed.
-
virtual void add ( Test* test ) ;
-
Add a test
This operation is used to add test cases and other sub-suites to the
test suite. It is not checked if this test is already contained in the
suite.
Protected Members:
-
vector<Test*> _tests ;
-
All contained tests.
The contained tests in the order in which they were inserted.
-
bool _breakOnFailure ;
-
Break on failure flag.
When true, executing the suite is stopped immediately when
one of the contained tests fails.
-
bool _success ;
-
Success status of the suite.
Signals the final outcome of the suite.
Altered during execution of the suite. Initially true,
goes to false as soon as one test fails.
The Scrunitizer C++ Unit Test Framework
by Bernd Linowski
[Scrunitizer]
[Overview]
[Cookbook]
[Download]
[Index]
[Linosphere]
Page generated: 1 Nov 2000
(C) by Bernd Linowski
scrunitizer@linosphere.de
|