Test base classThis is the base class for all types of tests that can be registered and run in a test application. More...

#include <cxxtools/unit/test.h>

Inheritance diagram for cxxtools::unit::Test:
cxxtools::Connectable cxxtools::NonCopyable cxxtools::unit::Application cxxtools::unit::TestCase cxxtools::unit::TestMethod cxxtools::unit::TestSuite cxxtools::unit::BasicTestMethod< C, A1, A2, A3, A4, A5, A6, A7, A8 > cxxtools::unit::BasicTestMethod< C, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void >

Public Member Functions

virtual ~Test ()
 Destructor.
virtual void run ()=0
 Runs the test.
const std::string & name () const
void reportStart (const TestContext &ctx)
 Reports the start of a test.
void reportFinish (const TestContext &ctx)
 Finished notification.
void reportSuccess (const TestContext &ctx)
 Success notification.
void reportAssertion (const TestContext &ctx, const Assertion &ass)
 Assertion notification.
void reportException (const TestContext &ctx, const std::exception &ex)
 Exception notification.
void reportError (const TestContext &ctx)
 Error notification.
void reportMessage (const std::string &msg)
 Message notification.
void setParent (Test *test)
Testparent ()
const Testparent () const
void attachReporter (Reporter &r)
 Add reporter for test events.
void detachReporter (Reporter &r)
- Public Member Functions inherited from cxxtools::Connectable
 Connectable ()
 Default constructor.
virtual ~Connectable ()
 Closes all connections.
virtual void onConnectionOpen (const Connection &c)
 Registers a Connection with the Connectable.
virtual void onConnectionClose (const Connection &c)
 Unregisters a Connection from the Connectable.
size_t connectionCount () const

Protected Member Functions

 Test (const std::string &name)
 Construct a test by name.
- Protected Member Functions inherited from cxxtools::Connectable
 Connectable (const Connectable &c)
 Copy constructor.
Connectableoperator= (const Connectable &rhs)
 Assignment operator.
const std::list< Connection > & connections () const
 Returns a list of all current connections.
std::list< Connection > & connections ()
 Returns a list of all current connections.
void clear ()
- Protected Member Functions inherited from cxxtools::NonCopyable
 NonCopyable ()

Additional Inherited Members

- Protected Attributes inherited from cxxtools::Connectable
std::list< Connection_connections
 A list of all current connections.

Detailed Description

Test base class

This is the base class for all types of tests that can be registered and run in a test application.

It provides a virtual method run that is overriden by the derived classes and signals to inform about events that occur while the test is run.

Constructor & Destructor Documentation

virtual cxxtools::unit::Test::~Test ( )
inlinevirtual

Destructor.

cxxtools::unit::Test::Test ( const std::string &  name)
inlineexplicitprotected

Construct a test by name.

Parameters
nameName of the test

Member Function Documentation

void cxxtools::unit::Test::attachReporter ( Reporter r)

Add reporter for test events.

Adds the reporter r to report test events. The caller owns the reporter and must make sure it lives as long as the test.

Reimplemented in cxxtools::unit::Application.

void cxxtools::unit::Test::detachReporter ( Reporter r)
const std::string& cxxtools::unit::Test::name ( ) const
Test* cxxtools::unit::Test::parent ( )
const Test* cxxtools::unit::Test::parent ( ) const
void cxxtools::unit::Test::reportAssertion ( const TestContext ctx,
const Assertion ass 
)

Assertion notification.

This signal is sent when a assertion failed.

void cxxtools::unit::Test::reportError ( const TestContext ctx)

Error notification.

This signal is sent when an unknown error occured.

void cxxtools::unit::Test::reportException ( const TestContext ctx,
const std::exception &  ex 
)

Exception notification.

This signal is sent when a regular std::exception occured.

void cxxtools::unit::Test::reportFinish ( const TestContext ctx)

Finished notification.

This signal is sent when the test finished. It does not indicate that the test was successful.

void cxxtools::unit::Test::reportMessage ( const std::string &  msg)

Message notification.

This signal can be sent to report informational messages.

void cxxtools::unit::Test::reportStart ( const TestContext ctx)

Reports the start of a test.

void cxxtools::unit::Test::reportSuccess ( const TestContext ctx)

Success notification.

This signal is sent when the test was successful.

virtual void cxxtools::unit::Test::run ( )
pure virtual

Runs the test.

Derived test classes are supposed to implement this method to run the test procedure. A derived class should send the 'started' signal at the begin of the test and send the 'finished' signal at the end of the test. If the test was successful, the 'success' signal is sent, otheriwse one of the signals indicating a failrue. In case of a failed assertion, the signal 'assertion' is sent, if a regular std::exception was the cause of the error the signal 'exception' is sent and and the signal 'error' indicates an unknown exception or error. This method should not propagate any exceptions

Implemented in cxxtools::unit::TestSuite, cxxtools::unit::BasicTestMethod< C, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void, cxxtools::Void >, cxxtools::unit::TestCase, cxxtools::unit::Application, cxxtools::unit::BasicTestMethod< C, A1, A2, A3, A4, A5, A6, A7, A8 >, and cxxtools::unit::TestMethod.

void cxxtools::unit::Test::setParent ( Test test)

The documentation for this class was generated from the following file:
  • include/cxxtools/unit/test.h