CppTest  Version 2.0.0
Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
Test::Suite Class Reference

#include <cpptest-suite.h>

Public Member Functions

 Suite ()
 
virtual ~Suite ()
 
void add (std::unique_ptr< Suite > suite)
 
bool run (Output &output, bool cont_after_fail=true)
 

Protected Types

typedef void(Suite::* Func) ()
 

Protected Member Functions

bool continue_after_failure () const
 
virtual void setup ()
 
virtual void tear_down ()
 
void register_test (Func func, const std::string &name)
 
void assertment (Source s)
 

Friends

struct DoRun
 
struct ExecTests
 
struct SubSuiteTests
 
struct SubSuiteTime
 

Detailed Description

Unit testing suite.

Base class for all suites. Derive from this class to create own test suites.

Test functions in derived classes are registered as tests using the TEST_ADD(func). Testing is started by run(). Note that suites may be embedded in other suites using add().

Member Typedef Documentation

◆ Func

typedef void(Suite::* Test::Suite::Func) ()
protected

Pointer to a test function.

Constructor & Destructor Documentation

◆ Suite()

Test::Suite::Suite ( )

Constructs an empty test suite.

◆ ~Suite()

Test::Suite::~Suite ( )
virtual

Destroys this suite object.

Member Function Documentation

◆ add()

void Test::Suite::add ( std::unique_ptr< Suite suite)

Adds a suite to this suite. Tests in added suites will be executed when run() of the top-level suite is called.

Parameters
suiteTest suite to add.

◆ run()

bool Test::Suite::run ( Output output,
bool  cont_after_fail = true 
)

Starts the testing. All tests in this suite and embedded suites will be executed.

Parameters
outputProgress report destination.
cont_after_failContinue functions despite failures.
Returns
True if no test failed; false otherwise.

References Test::Output::finished(), and Test::Output::initialize().

◆ setup()

void Test::Suite::setup ( )
inlineprotectedvirtual

Setups a test fixture. This function is called before each test, in this suite, is executed.

This function should be overloaded by derived classes to provide specialized behavior.

See also
tear_down()

◆ tear_down()

void Test::Suite::tear_down ( )
inlineprotectedvirtual

Tears down a test fixture. This function is called after each test, in this suite, have been executed.

This function should be overloaded by derived classes to provide specialized behavior.

See also
setup()

◆ register_test()

void Test::Suite::register_test ( Func  func,
const std::string &  name 
)
protected

Registers a test function.

Note: Do not call this function directly, use the TEST_ADD(func) macro instead.

Parameters
funcPointer to a test function.
nameClass and function name of the function. The format must equal class::func.

◆ assertment()

void Test::Suite::assertment ( Source  s)
protected

Issues an assertment to the output handler.

Do not call this function directly, use one of the available assertment macros instead, see Available asserts.

Parameters
sAssert point information.

References Test::Output::assertment().


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