Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

easyunit::Test Class Reference

Test class containing all macros to do unit testing. More...

#include <test.h>

List of all members.

Public Member Functions

 Test (const SimpleString &testCaseName, const SimpleString &testName)
 Main Test constructor.
virtual ~Test ()
 Main Test desctructor Delete the testPartResult linked list.
virtual void tearDown ()
 Fixtures that will be called after run().
virtual void setUp ()
 Fixtures that will be called before run().
virtual void run ()
 Test code should be in this method.
void setTestCase (TestCase *testCase)
 Set the TestCase this test belongs to.
TestCasegetTestCase () const
 Get the TestCase this test belongs to.
virtual void addTestPartResult (TestPartResult *testPartResult)
 Add a testpartresult to the testpartresult list of this test.
TestPartResultgetTestPartResult () const
 Get the testpartresult list of this test.
int getFailuresCount () const
 Returns number of failures found in this test.
int getSuccessesCount () const
 Returns number of successes found in this test.
int getErrorsCount () const
 Returns number of errors found in this test.
void setNext (Test *nextTest)
 Set the next test in the linked list.
TestgetNext () const
 Get the next test in the linked list.
const SimpleStringgetTestCaseName () const
 Get the name of the TestCase this test belongs to.
const SimpleStringgetTestName () const
 Get the name of this test.

Protected Attributes

SimpleString testCaseName_
SimpleString testName_
TestCasetestCase_
TestPartResulttestPartResult_
TestnextTest_
int failuresCount_
int successesCount_
int errorsCount_


Detailed Description

Test class containing all macros to do unit testing.

A test object represents a test that will be executed. Once it has been executed, it reports all results in the testPartResult linked list.

A failure occurs when a test fails (condition is false). An error occurs when an exception is thrown during a test. A success occurs if a test succeed (condition is true).


Constructor & Destructor Documentation

easyunit::Test::Test const SimpleString testCaseName,
const SimpleString testName
 

Main Test constructor.

Used to create a test that will register itself with TestRegistry and with its test case.

Parameters:
testCaseName Name of the test case this test belongs to
testName Name of this test

virtual easyunit::Test::~Test  )  [virtual]
 

Main Test desctructor Delete the testPartResult linked list.

This is why the user should only use the macro provided by easyunit to report a test result.


Member Function Documentation

virtual void easyunit::Test::addTestPartResult TestPartResult testPartResult  )  [virtual]
 

Add a testpartresult to the testpartresult list of this test.

This method is used by the assertion macros to report success, failure or error.

Parameters:
testPartResult The testpartresult to be added to the list

int easyunit::Test::getErrorsCount  )  const
 

Returns number of errors found in this test.

ErrorsCount <= 1, since exception are caught for the whole run() method.

Returns:
Number of errors in this test

int easyunit::Test::getFailuresCount  )  const
 

Returns number of failures found in this test.

If macro TEST or TESTF is used, failuresCount <= 1. If Test class is extended and ASSERT macros are used in different test methods, than failuresCount may be more than 1.

Returns:
Number of failures in this test

Test* easyunit::Test::getNext  )  const
 

Get the next test in the linked list.

Returns:
The next test in the linked list

int easyunit::Test::getSuccessesCount  )  const
 

Returns number of successes found in this test.

There may be more than one success since each ASSERT macro that succeeded generate a success.

Returns:
Number of successes in this test

TestCase* easyunit::Test::getTestCase  )  const
 

Get the TestCase this test belongs to.

A test always belongs to only one TestCase. This is the TestCase identified by the first parameter of the test declaration. For example, if there is a test declared as TEST(TESTCASE1, TEST1), this test will be associated with the TestCase TESTCASE1.

Returns:
The TestCase this test belongs to

const SimpleString& easyunit::Test::getTestCaseName  )  const
 

Get the name of the TestCase this test belongs to.

The name of the TestCase is the first parameter of the test declaration. For example, if a test is declared as TEST(TESTCASE1, TEST1), this method will return "TESTCASE1".

Returns:
The TestCase name of this test

const SimpleString& easyunit::Test::getTestName  )  const
 

Get the name of this test.

The name of the test is the second parameter of the test declaration. For example, if a test is declared as TEST(TESTCASE1, TEST1), this method will return "TEST1".

Returns:
The name of this test.

TestPartResult* easyunit::Test::getTestPartResult  )  const
 

Get the testpartresult list of this test.

If assertion macros and TEST and TESTF macros are used, there may be more than one successful testpartresult and no more than one error or failure.

Returns:
testPartResult The list of testpartresults of this test

virtual void easyunit::Test::run  )  [virtual]
 

Test code should be in this method.

run() will be called by the Test's TestCase, hence subclasses of Test should override this method.

void easyunit::Test::setNext Test nextTest  ) 
 

Set the next test in the linked list.

Parameters:
nextTest Next test in the linked list

void easyunit::Test::setTestCase TestCase testCase  ) 
 

Set the TestCase this test belongs to.

Parameters:
testCase The TestCase this test belongs to

virtual void easyunit::Test::setUp  )  [virtual]
 

Fixtures that will be called before run().

virtual void easyunit::Test::tearDown  )  [virtual]
 

Fixtures that will be called after run().


Member Data Documentation

int easyunit::Test::errorsCount_ [protected]
 

int easyunit::Test::failuresCount_ [protected]
 

Test* easyunit::Test::nextTest_ [protected]
 

int easyunit::Test::successesCount_ [protected]
 

TestCase* easyunit::Test::testCase_ [protected]
 

SimpleString easyunit::Test::testCaseName_ [protected]
 

SimpleString easyunit::Test::testName_ [protected]
 

TestPartResult* easyunit::Test::testPartResult_ [protected]
 


The documentation for this class was generated from the following file:
Generated on Fri Mar 4 09:51:25 2005 for EasyUnit by doxygen 1.3.8