ApparatusFramework::TestSuite Class Reference
[Unit-Test Services]

#include <UnitTestServices/current/include/TestSuit.h>

List of all members.

Public Member Functions

 TestSuite ()
virtual ~TestSuite ()
void addTestSuite (TestSuite *pTestSuite)
virtual const char * getName () const
void run (const char *testSpecifier="*")
void run (unsigned int shallNumber, int hierarchy=0, unsigned int isNumber=0)
void listAddedTestSuites (int hierarchy=0, int number=0)

Protected Member Functions

virtual void setUp ()
virtual void testCases ()=0
virtual void tearDown ()
void delayFor (const unsigned long int timeout)
char * toString (const int value, char *theString=0)
char * toString (const void *pointer, char *theString=0)
void assertLogMet (StubInterface &stub, const char *logEntry, const unsigned short timeout, const char *fileName, const int line)
void assertStringMet (const char *left, const char *right, const char *fileName, const int line)
void assertIntegerMet (long int left, long int right, const char *fileName, const int line)

Detailed Description

The TestSuite class implements the basic funtionality of a test suite. A test suite is usually executed by setting up the environment, running a number of test cases (or other test suites) and then tear down the special environment. This is represented by the run method, which does exactly this. We also provide three generic functions to test log entries, integers and strings.

The test suite class needs access to some standard output where it can report any errors it has discovered. No other facilities are needed. If the logger of the ApparatusFramework is available (Logger), it is used automatically for reporting.

Definition at line 106 of file TestSuit.h.


Constructor & Destructor Documentation

ApparatusFramework::TestSuite::TestSuite (  ) 

constructors, destructors Constructs a new TestSuite object.

virtual ApparatusFramework::TestSuite::~TestSuite (  )  [virtual]

Destroys the object and releases all the associated resources.


Member Function Documentation

void ApparatusFramework::TestSuite::addTestSuite ( TestSuite pTestSuite  ) 

modifiers This method allows you to add a new test class (derived from TestSuite), which will then be executed by starting its run() method.

Parameters:
pTestSuite pointer to the test suite class to be added.
void ApparatusFramework::TestSuite::assertIntegerMet ( long int  left,
long int  right,
const char *  fileName,
const int  line 
) [protected]

Makes sure that the two integers are equal. This method is usually not called directly but via the assertInteger macro.

Parameters:
left first integer to be compared.
right second integer to be compared.
fileName name of the file where the assertion is done.
line line of code where the assertion is done.
void ApparatusFramework::TestSuite::assertLogMet ( StubInterface stub,
const char *  logEntry,
const unsigned short  timeout,
const char *  fileName,
const int  line 
) [protected]

Makes sure that the expected log is written to the specified stub within the given time. Then clears the log. This method is usually not called directly but via the assertLog macro.

Parameters:
stub reference to the stub where the log is expected.
logEntry the expected log entry.
timeout time in milliseconds until the log has to be written.
fileName name of the file where the assertion is done.
line line of code where the assertion is done.
void ApparatusFramework::TestSuite::assertStringMet ( const char *  left,
const char *  right,
const char *  fileName,
const int  line 
) [protected]

Makes sure that the two string are equal. This method is usually not called directly but via the assertString macro.

Parameters:
left first string to be compared.
right second string to be compared.
fileName name of the file where the assertion is done.
line line of code where the assertion is done.
void ApparatusFramework::TestSuite::delayFor ( const unsigned long int  timeout  )  [protected]

helpers Delays the test execution until the given interval of time has elapsed.

Parameters:
timeout timeout in milliseconds to wait before the test suite is again ready for execution.
virtual const char* ApparatusFramework::TestSuite::getName (  )  const [virtual]

queries Returns the name of this Test Suite.

Returns:
the name of this test suite.
void ApparatusFramework::TestSuite::listAddedTestSuites ( int  hierarchy = 0,
int  number = 0 
)

list functions Prints out a list of the added test suites.

Parameters:
hierarchy A variable which holds the depth of the recursion.
number Test suite number of this hierarchy.
void ApparatusFramework::TestSuite::run ( unsigned int  shallNumber,
int  hierarchy = 0,
unsigned int  isNumber = 0 
)

Executes a specific test suite number. These numbers can be seen using the listAddedTestSuites method.

Parameters:
shallNumber the test case number that shall be executed.
hierarchy a variable which holds the depth of the recursion.
isNumber the actual test suite number.
void ApparatusFramework::TestSuite::run ( const char *  testSpecifier = "*"  ) 

Executes the test suite by calling the setUp method, running the testCases and then calling tearDown.

Parameters:
testSpecifier specifies which nested Test Suite should be run. If the wildecard "*" is specified, all Test Suites are run (default).
virtual void ApparatusFramework::TestSuite::setUp (  )  [inline, protected, virtual]

test steps Sets up the environment so that the test cases can run. Installs stubs, establishes pre-conditions.

Definition at line 157 of file TestSuit.h.

virtual void ApparatusFramework::TestSuite::tearDown (  )  [inline, protected, virtual]

Tears down the environment that has been set up for the test cases. Installs the original classes instead of the stubs.

Definition at line 167 of file TestSuit.h.

virtual void ApparatusFramework::TestSuite::testCases (  )  [protected, pure virtual]

Calls the test cases. In debug mode, the execution of the program is halted if a test notices an error.

char* ApparatusFramework::TestSuite::toString ( const void *  pointer,
char *  theString = 0 
) [protected]

Converts any pointer to a string.

Parameters:
pointer the pointer to be converted.
theString pointer to a char array big enough to hold the converted pointer. Only needed when this method is used from multiple threads.
Returns:
char* pointer to the converted pointer.
char* ApparatusFramework::TestSuite::toString ( const int  value,
char *  theString = 0 
) [protected]

Converts an int value to a string.

Parameters:
value the int value to be converted.
theString pointer to a char array big enough to hold the converted value. Only needed when this method is used from multiple threads.
Returns:
char* pointer to the converted value.
© 2004-2010 bbv Software Services AG / Apparatus Services