CppUnit project page FAQ

Public Member Functions | Private Member Functions | Private Attributes | List of all members
TestCase Class Reference

A single test object. More...

#include <TestCase.h>

Inheritance diagram for TestCase:
Inheritance graph
[legend]
Collaboration diagram for TestCase:
Collaboration graph
[legend]

Public Member Functions

 TestCase (const std::string &name)
 Constructs a test case. More...
 
 TestCase ()
 Constructs a test case for a suite. More...
 
 ~TestCase ()
 Destructs a test case. More...
 
virtual void run (TestResult *result)
 Run the test and catch any exceptions that are triggered by it. More...
 
std::string getName () const
 Returns the name of the test case. More...
 
virtual void runTest ()
 FIXME: this should probably be pure virtual. More...
 
- Public Member Functions inherited from TestLeaf
int countTestCases () const
 
int getChildTestCount () const
 
TestdoGetChildTestAt (int index) const
 
- Public Member Functions inherited from Test
virtual ~Test ()
 
virtual TestgetChildTestAt (int index) const
 Returns the child test of the specified index. More...
 
virtual bool findTestPath (const std::string &testName, TestPath &testPath) const
 Finds the test with the specified name and its parents test. More...
 
virtual bool findTestPath (const Test *test, TestPath &testPath) const
 Finds the specified test and its parents test. More...
 
virtual TestfindTest (const std::string &testName) const
 Finds the test with the specified name in the hierarchy. More...
 
virtual TestPath resolveTestPath (const std::string &testPath) const
 Resolved the specified test path with this test acting as 'root'. More...
 
- Public Member Functions inherited from TestFixture
virtual ~TestFixture ()
 
virtual void setUp ()
 Set up context before running a test. More...
 
virtual void tearDown ()
 Clean up after the test run. More...
 

Private Member Functions

 TestCase (const TestCase &other)
 
TestCaseoperator= (const TestCase &other)
 

Private Attributes

const std::string m_name
 

Additional Inherited Members

- Protected Member Functions inherited from Test
virtual void checkIsValidIndex (int index) const
 

Detailed Description

A single test object.

This class is used to implement a simple test case: define a subclass that overrides the runTest method.

You don't usually need to use that class, but TestFixture and TestCaller instead.

You are expected to subclass TestCase is you need to write a class similiar to TestCaller.

Constructor & Destructor Documentation

◆ TestCase() [1/3]

TestCase::TestCase ( const std::string &  name)

Constructs a test case.

Parameters
namethe name of the TestCase.

◆ TestCase() [2/3]

TestCase::TestCase ( )

Constructs a test case for a suite.

Deprecated:
This constructor was used by fixture when TestFixture did not exist. Have your fixture inherits TestFixture instead of TestCase.

◆ ~TestCase()

TestCase::~TestCase ( )

Destructs a test case.

◆ TestCase() [3/3]

TestCase::TestCase ( const TestCase other)
private

Member Function Documentation

◆ getName()

std::string TestCase::getName ( ) const
virtual

Returns the name of the test case.

Implements Test.

◆ operator=()

TestCase& TestCase::operator= ( const TestCase other)
private

◆ run()

void TestCase::run ( TestResult result)
virtual

Run the test and catch any exceptions that are triggered by it.

Implements Test.

◆ runTest()

void TestCase::runTest ( )
virtual

FIXME: this should probably be pure virtual.

All the work for runTest is deferred to subclasses.

Reimplemented in TestCaller< Fixture >, TestCaseDecorator, Orthodox< ClassUnderTest >, and ExceptionTestCaseDecorator< ExpectedException >.

Member Data Documentation

◆ m_name

const std::string TestCase::m_name
private

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

Send comments to:
CppUnit Developers