Webmaster  |  Imprint 
Platinum
Platinum C++ Framework
Main  |  License  |  Documentation  |  Download  |  Support 

Test Class Reference
[UnitTests]

Test base class. More...

#include <Pt/Unit/Test.h>

Inheritance diagram for Test:

Connectable NonCopyable Application TestCase TestSuite ITestSuite

List of all members.

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)

Protected Member Functions

 Test (const std::string &name)
 Construct a test by name.


Detailed Description

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

Test ( const std::string &  name  )  [explicit, protected]

Parameters:
name Name of the test


Member Function Documentation

virtual void run (  )  [pure virtual]

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 Application, TestCase, and TestSuite.

void reportFinish ( const TestContext &  ctx  ) 

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

void reportSuccess ( const TestContext &  ctx  ) 

This signal is sent when the test was successful.

void reportAssertion ( const TestContext &  ctx,
const Assertion ass 
)

This signal is sent when a assertion failed.

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

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

void reportError ( const TestContext &  ctx  ) 

This signal is sent when an unknown error occured.

void reportMessage ( const std::string &  msg  ) 

This signal can be sent to report informational messages.

void attachReporter ( Reporter r  ) 

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 Application.

Copyright © 2003-2007 The Pt Development Team
Pt 1.0