CppUnit project page CppUnit home page

Test case & test suite


Classes

class  CppUT::ExceptionGuardElement
class  CppUT::ExceptionTranslatorGuard< ExceptionType, Translator >
 Helpers to provide simple exception translation. More...
class  CppUT::ExceptionGuard
class  CppUT::Test
class  CppUT::AbstractTestCase
 An abstract test case that can be run. More...
class  CppUT::TestCase
 A test case that can be run. More...
class  CppUT::AbstractTestSuite
 An abstract test suite that represents a collection of Test. More...
class  CppUT::TestSuite
 A test suite that represents a collection of Test. More...

Functions

template<class Translator, class ExceptionType>
void CppUT::registerExceptionTranslation (ExceptionGuard &guard, Translator translator, CppTL::Type< ExceptionType >)
 Register an exception translator.
TestPtr CppUT::makeTestCase (void(*run)(), const std::string &name)
 Creates a TestCase with the specified name and run functor.
TestPtr CppUT::makeTestCase (const CppTL::Functor0 &run, const std::string &name)
 Creates a TestCase with the specified name and run functor.
TestPtr CppUT::makeTestCase (const CppTL::Functor0 &setUp, const CppTL::Functor0 &run, const CppTL::Functor0 &tearDown, const std::string &name)
 Creates a TestCase with the specified name and setUp, run, and tearDown functor.
TestPtr CppUT::makeFailingTestCase (const std::string &name, const Message &message)
 Creates a TestCase with the specified name that will always fail.

The test case run body simply call CPPUT_FAIL() with the specified message.

template<typename FixtureType>
TestPtr CppUT::makeFixtureTestCase (const CppTL::IntrusivePtr< FixtureType > &fixture, const CppTL::Functor0 &run, const std::string &name)
 Creates a TestCase using a fixture-like object.

The test case will delegate implementation of AbstractTestCase setUp() and tearDown() to method of the same name on the given fixture object.

TestSuitePtr CppUT::makeTestSuite (const std::string &name)
 Creates a TestSuite with the specified name.

Function Documentation

TestPtr CppUT::makeFailingTestCase ( const std::string &  name,
const Message &  message 
)

Creates a TestCase with the specified name that will always fail.

The test case run body simply call CPPUT_FAIL() with the specified message.

This is useful for example when a TestSuite is created from input data and those an invalid or inaccessible. A failing test case can be added to the suite to report the error.

template<typename FixtureType>
TestPtr CppUT::makeFixtureTestCase ( const CppTL::IntrusivePtr< FixtureType > &  fixture,
const CppTL::Functor0 run,
const std::string &  name 
) [inline]

Creates a TestCase using a fixture-like object.

The test case will delegate implementation of AbstractTestCase setUp() and tearDown() to method of the same name on the given fixture object.

Todo:
Use traits to get smart-pointer type and allow for any type of smart-pointer

References CppUT::makeTestCase(), and CppTL::memfn0().

TestPtr CppUT::makeTestCase ( const CppTL::Functor0 setUp,
const CppTL::Functor0 run,
const CppTL::Functor0 tearDown,
const std::string &  name 
)

Creates a TestCase with the specified name and setUp, run, and tearDown functor.

References CppUT::TestCase::TestCase().

TestPtr CppUT::makeTestCase ( const CppTL::Functor0 run,
const std::string &  name 
)

Creates a TestCase with the specified name and run functor.

References CppUT::TestCase::TestCase().

TestPtr CppUT::makeTestCase ( void(*)()  run,
const std::string &  name 
)

Creates a TestCase with the specified name and run functor.

References CppTL::cfn0(), CppUT::TestCase::run(), and CppUT::TestCase::TestCase().

Referenced by CppUT::makeFixtureTestCase(), and CppUT::TestFunctionFactory::operator()().

TestSuitePtr CppUT::makeTestSuite ( const std::string &  name  ) 

Creates a TestSuite with the specified name.

References CppUT::TestSuite::TestSuite().

Referenced by CppUT::Registry::createDefaultTests(), and CppUT::Registry::createTests().

template<class Translator, class ExceptionType>
void CppUT::registerExceptionTranslation ( ExceptionGuard &  guard,
Translator  translator,
CppTL::Type< ExceptionType >   
) [inline]

Register an exception translator.

Todo:
provides some helper to generate fault result...
 static void translateMFCException( CException *e ) {
     TCHAR   szCause[255];
     ex.GetErrorMessage(szCause, 255);
     CString str( szCause );

     OpenTest::Properties fault;
     fault["type"] = "unexpected exception";
     fault["exception_type"] = "CException";
     fault["message"].append( (const char *)str );
     TestInfo::appendFaultToResult( fault );
 }    
Warning:
Ensure that either a fault, assertion is added to TestInfo, or that TestStatus is set to failed otherwise the test will not fail!

References CppUT::ExceptionGuard::append().


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