CppUnit project page CppUnit home page

CppUT::AbstractTestCase Class Reference
[Test case & test suite]

An abstract test case that can be run. More...

#include <cpput/testcase.h>

Inheritance diagram for CppUT::AbstractTestCase:

Inheritance graph
[legend]
Collaboration diagram for CppUT::AbstractTestCase:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 AbstractTestCase (const std::string &name)
void requireResource (const std::string &resourceName)
 Indicates that the test case requires the specified resource.
void prepareResourceAcquisition ()
 Prepare the acquisition of resource at the beginning of the test run.
bool runTest ()
 Run the test case using the default ExceptionGuard.
bool runTest (const ExceptionGuard &guardsChain)
 Run the test case using the specified ExceptionGuard.
void accept (TestVisitor &visitor)
bool isTestCase () const
 Returns true if the class is derived from AbstractTestCase.
virtual void setUp ()
virtual void run ()=0
virtual void tearDown ()


Detailed Description

An abstract test case that can be run.

Constructor & Destructor Documentation

CppUT::AbstractTestCase::AbstractTestCase ( const std::string &  name  ) 


Member Function Documentation

void CppUT::AbstractTestCase::requireResource ( const std::string &  resourceName  ) 

Indicates that the test case requires the specified resource.

The specified resource will be acquired before calling setUp() and will be at the earliest after calling tearDown().

Parameters:
resourceName Name of the resource to acquire.
See also:
ResourceHandlerRegistry, getResource().

void CppUT::AbstractTestCase::prepareResourceAcquisition (  ) 

Prepare the acquisition of resource at the beginning of the test run.

This must be called at the beginning of the test run for each test case. It allows couting how many time a resource will be used and during the test run, determining when a resource is no longer needed to free it.

A ResourceLazyPtr is obtained for each required resource via the ResourceHandlerRegistry.

bool CppUT::AbstractTestCase::runTest (  ) 

Run the test case using the default ExceptionGuard.

The default exception guard only detect

Referenced by CppUT::OpenTestAdaptor::runTests().

bool CppUT::AbstractTestCase::runTest ( const ExceptionGuard guardsChain  ) 

Run the test case using the specified ExceptionGuard.

Call TestInfo::startNewTest() before starting the test. Then, setUp(), run() and finally tearDown() are called. run() is only called if setUp() did not failed (no assertion or exception failed during setUp() call).

Parameters:
guardsChain Call to setUp(), run() and tearDown() are made through the specified exception guard. This allow capturing and extracting information for failure report from exception that do not subclass std::exception.

References CppTL::bind(), CppUT::TestInfo::discardTestResources(), CppUT::TestStatus::hasFailed(), CppTL::memfn0(), CppTL::memfn1(), CppUT::ExceptionGuard::protect(), CppTL::ref(), run(), setUp(), CppUT::TestInfo::startNewTest(), tearDown(), CppUT::TestInfo::testStatus(), and CppUT::TestInfo::threadInstance().

void CppUT::AbstractTestCase::accept ( TestVisitor visitor  )  [virtual]

bool CppUT::AbstractTestCase::isTestCase (  )  const [virtual]

Returns true if the class is derived from AbstractTestCase.

Implements CppUT::Test.

void CppUT::AbstractTestCase::setUp (  )  [virtual]

Reimplemented in CppUT::TestCase.

Referenced by runTest().

virtual void CppUT::AbstractTestCase::run (  )  [pure virtual]

Implemented in CppUT::TestCase.

Referenced by runTest().

void CppUT::AbstractTestCase::tearDown (  )  [virtual]

Reimplemented in CppUT::TestCase.

Referenced by runTest().


The documentation for this class was generated from the following files:

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers