cxxtools::unit::JsonReporter Class Reference

This class collects test results and makes them serialziable. More...

#include <cxxtools/unit/jsonreporter.h>

Inheritance diagram for cxxtools::unit::JsonReporter:
cxxtools::unit::Reporter

Public Member Functions

 JsonReporter ()
virtual void reportStart (const cxxtools::unit::TestContext &test)
 Start notification.
virtual void reportFinish (const cxxtools::unit::TestContext &test)
 Finished notification.
virtual void reportMessage (const std::string &msg)
 Message notification.
virtual void reportSuccess (const cxxtools::unit::TestContext &test)
 Success notification.
virtual void reportAssertion (const cxxtools::unit::TestContext &test, const cxxtools::unit::Assertion &a)
 Assertion notification.
virtual void reportException (const cxxtools::unit::TestContext &test, const std::exception &ex)
 Exception notification.
virtual void reportError (const cxxtools::unit::TestContext &test)
 Error notification.
virtual void reportSkip (const cxxtools::unit::TestContext &test)
 Skipped notification.
- Public Member Functions inherited from cxxtools::unit::Reporter
virtual ~Reporter ()
 Destructor.

Friends

void operator<<= (cxxtools::SerializationInfo &si, const JsonReporter &result)

Additional Inherited Members

- Public Attributes inherited from cxxtools::unit::Reporter
Signal< Reporter & > destroyed
- Protected Member Functions inherited from cxxtools::unit::Reporter
 Reporter ()
 Constructs a reporter.

Detailed Description

This class collects test results and makes them serialziable.

The name of the class is somewhat misleading since it can be used as well with xml serializer.

To use it, attach the reporter to the test application. When the tests were run, output the reporter with a suitable serializer like the json serializer.

// instantiate the test application
// create a JsonReporter and attach it to the app
JsonReporter reporter;
app.attachReporter(reporter);
// run all registered tests
app.run();
// output the results in json format
std::cout << cxxtools::Json(reporter).beautify(true);

Constructor & Destructor Documentation

cxxtools::unit::JsonReporter::JsonReporter ( )
inline

Member Function Documentation

virtual void cxxtools::unit::JsonReporter::reportAssertion ( const cxxtools::unit::TestContext ,
const cxxtools::unit::Assertion  
)
virtual

Assertion notification.

This method is called when a an assertion failed during a test. an assertion fails when a user defined condition is not met.

Parameters
testThe failed test

Reimplemented from cxxtools::unit::Reporter.

virtual void cxxtools::unit::JsonReporter::reportError ( const cxxtools::unit::TestContext )
virtual

Error notification.

This method is called when a an unknown error occurs during a test.

Parameters
testThe failed test

Reimplemented from cxxtools::unit::Reporter.

virtual void cxxtools::unit::JsonReporter::reportException ( const cxxtools::unit::TestContext ,
const std::exception &   
)
virtual

Exception notification.

This method is called when a an exception failed during a test. An exception usually means that an error occured that was even u nexpected in a test scenario

Parameters
testThe failed test

Reimplemented from cxxtools::unit::Reporter.

virtual void cxxtools::unit::JsonReporter::reportFinish ( const cxxtools::unit::TestContext )
virtual

Finished notification.

This method is called when a test has finished. Every test sends this signal at its end no matter if it failed or succeeded.

Parameters
testThe finished test

Reimplemented from cxxtools::unit::Reporter.

virtual void cxxtools::unit::JsonReporter::reportMessage ( const std::string &  )
virtual

Message notification.

This method is called when a test has produced an informational message.

Parameters
msgThe message

Reimplemented from cxxtools::unit::Reporter.

virtual void cxxtools::unit::JsonReporter::reportSkip ( const cxxtools::unit::TestContext )
virtual

Skipped notification.

This method is called when was skipped.

Parameters
testThe skipped test

Reimplemented from cxxtools::unit::Reporter.

virtual void cxxtools::unit::JsonReporter::reportStart ( const cxxtools::unit::TestContext )
virtual

Start notification.

This method is called when a test has started. Every test sends this signal at startup.

Parameters
testThe started test

Reimplemented from cxxtools::unit::Reporter.

virtual void cxxtools::unit::JsonReporter::reportSuccess ( const cxxtools::unit::TestContext )
virtual

Success notification.

This method is called when a test was successful.

Parameters
testThe succeeded test

Reimplemented from cxxtools::unit::Reporter.

Friends And Related Function Documentation

void operator<<= ( cxxtools::SerializationInfo si,
const JsonReporter result 
)
friend

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