OTest2
A C++ testing framework
Classes | Public Member Functions | List of all members
OTest2::ReporterJUnit Class Reference

A reporter creating JUnit XML reports. More...

#include <reporterjunit.h>

Inheritance diagram for OTest2::ReporterJUnit:
Inheritance graph
[legend]
Collaboration diagram for OTest2::ReporterJUnit:
Collaboration graph
[legend]

Classes

struct  Impl
 

Public Member Functions

 ReporterJUnit (const std::string &file_, bool hide_location_)
 Ctor. More...
 
virtual ~ReporterJUnit ()
 Dtor. More...
 
 ReporterJUnit (const ReporterJUnit &)=delete
 
ReporterJUnitoperator= (const ReporterJUnit &)=delete
 
virtual void enterTest (const Context &context_, const std::string &name_, const Parameters &params_) override
 Enter entire test. More...
 
virtual void enterSuite (const Context &context_, const std::string &name_, const Parameters &params_) override
 Enter a suite. More...
 
virtual void enterCase (const Context &context_, const std::string &name_, const Parameters &params_) override
 Enter a case. More...
 
virtual void enterState (const Context &context_, const std::string &name_) override
 Enter a state. More...
 
virtual AssertBufferPtr enterAssert (const Context &context_, bool condition_, const std::string &file_, int lineno_) override
 Enter an assertion. More...
 
virtual AssertBufferPtr enterError (const Context &context_) override
 Enter an error report. More...
 
virtual void leaveState (const Context &context_, const std::string &name_, bool result_) override
 Leave a state. More...
 
virtual void leaveCase (const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
 Leave a case. More...
 
virtual void leaveSuite (const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
 Leave a suite. More...
 
virtual void leaveTest (const Context &context_, const std::string &name_, const Parameters &params_, bool result_) override
 Leave entire test. More...
 
- Public Member Functions inherited from OTest2::Reporter
 Reporter (const Reporter &)=delete
 
Reporteroperator= (const Reporter &)=delete
 
 Reporter ()
 Ctor. More...
 
virtual ~Reporter ()
 Dtor. More...
 

Detailed Description

A reporter creating JUnit XML reports.

Definition at line 32 of file reporterjunit.h.

Constructor & Destructor Documentation

◆ ReporterJUnit() [1/2]

OTest2::ReporterJUnit::ReporterJUnit ( const std::string &  file_,
bool  hide_location_ 
)
explicit

Ctor.

Parameters
file_filename of the generated XML report
hide_location_If it's true the location information (file and line number is omitted in the generated XML file.

Definition at line 285 of file reporterjunit.cpp.

◆ ~ReporterJUnit()

OTest2::ReporterJUnit::~ReporterJUnit ( )
virtual

Dtor.

Definition at line 292 of file reporterjunit.cpp.

◆ ReporterJUnit() [2/2]

OTest2::ReporterJUnit::ReporterJUnit ( const ReporterJUnit )
delete

Member Function Documentation

◆ enterAssert()

AssertBufferPtr OTest2::ReporterJUnit::enterAssert ( const Context context_,
bool  condition_,
const std::string &  file_,
int  lineno_ 
)
overridevirtual

Enter an assertion.

The assertion is opened similarly to states, cases and suites until the AsssertBuffer::commitAssertion() method of the returned assertion buffer is invoked.

Warning
Just one assertion at time may be opened!
Parameters
context_the OTest2 context
condition_result of the assertion (false means failed assertion)
file_name of the source file
lineno_line number in the source file
Returns
An assertion buffer object which is used for formatting the assertion report.

Implements OTest2::Reporter.

Definition at line 358 of file reporterjunit.cpp.

◆ enterCase()

void OTest2::ReporterJUnit::enterCase ( const Context context_,
const std::string &  name_,
const Parameters params_ 
)
overridevirtual

Enter a case.

Parameters
context_the OTest2 context
name_Name of the case
params_Parameters of the testing object

Implements OTest2::Reporter.

Definition at line 335 of file reporterjunit.cpp.

◆ enterError()

AssertBufferPtr OTest2::ReporterJUnit::enterError ( const Context context_)
overridevirtual

Enter an error report.

This method is used to report errors happened in the testing framework. Errors mean failure of the test. However, they cannot be located in the user code (no filename, no line number). A good example is a not handled exception caught by the framework outside test cases.

The method works as well as the enterAssert() method with failed condition and with no location info. The opened error state is closed by the AssertBuffer::commitAssertion() method of the returned assertion buffer.

Warning
Just one assertion at time may be opened!
Parameters
context_the context
Returns
An assertion buffer object which is used for formatting the assertion report.

Implements OTest2::Reporter.

Definition at line 376 of file reporterjunit.cpp.

◆ enterState()

void OTest2::ReporterJUnit::enterState ( const Context context_,
const std::string &  name_ 
)
overridevirtual

Enter a state.

Parameters
context_the OTest2 context
name_Name of the state

Implements OTest2::Reporter.

Definition at line 352 of file reporterjunit.cpp.

◆ enterSuite()

void OTest2::ReporterJUnit::enterSuite ( const Context context_,
const std::string &  name_,
const Parameters params_ 
)
overridevirtual

Enter a suite.

Parameters
context_the OTest2 context
name_Name of the suite
params_Parameters of the testing object

Implements OTest2::Reporter.

Definition at line 317 of file reporterjunit.cpp.

◆ enterTest()

void OTest2::ReporterJUnit::enterTest ( const Context context_,
const std::string &  name_,
const Parameters params_ 
)
overridevirtual

Enter entire test.

Parameters
context_The OTest2 context
name_Name of the test
params_Parameters of the testing object

Implements OTest2::Reporter.

Definition at line 296 of file reporterjunit.cpp.

◆ leaveCase()

void OTest2::ReporterJUnit::leaveCase ( const Context context_,
const std::string &  name_,
const Parameters params_,
bool  result_ 
)
overridevirtual

Leave a case.

Parameters
context_the OTest2 context
name_Name of the case
params_Parameters of the testing object
result_Result of the case

Implements OTest2::Reporter.

Definition at line 396 of file reporterjunit.cpp.

◆ leaveState()

void OTest2::ReporterJUnit::leaveState ( const Context context_,
const std::string &  name_,
bool  result_ 
)
overridevirtual

Leave a state.

Parameters
context_the OTest2 context
name_Name of the state
result_Result of the state

Implements OTest2::Reporter.

Definition at line 389 of file reporterjunit.cpp.

◆ leaveSuite()

void OTest2::ReporterJUnit::leaveSuite ( const Context context_,
const std::string &  name_,
const Parameters params_,
bool  result_ 
)
overridevirtual

Leave a suite.

Parameters
context_the OTest2 context
name_Name of the suite
params_Parameters of the testing object
result_Result of the suite

Implements OTest2::Reporter.

Definition at line 411 of file reporterjunit.cpp.

◆ leaveTest()

void OTest2::ReporterJUnit::leaveTest ( const Context context_,
const std::string &  name_,
const Parameters params_,
bool  result_ 
)
overridevirtual

Leave entire test.

Parameters
context_the OTest2 context
name_Name of the leaving test
params_Parameters of the testing object
result_Result of the test

Implements OTest2::Reporter.

Definition at line 427 of file reporterjunit.cpp.

◆ operator=()

ReporterJUnit& OTest2::ReporterJUnit::operator= ( const ReporterJUnit )
delete

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