Jon Test
C++ Unit Test Tool. Not for production -- sample code only
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
JonTest::StreamLogger Class Reference

Stream-based Logger for events while running tests. More...

#include <Logger.h>

Inheritance diagram for JonTest::StreamLogger:
Inheritance graph
Collaboration diagram for JonTest::StreamLogger:
Collaboration graph

Public Member Functions

 StreamLogger (std::ostream &out, bool verbose)
 Construct the Stream Logger to write to out with the given verbosity.
 
virtual ~StreamLogger ()
 Destructor – does nothing.
 
virtual void start ()
 Start of all testing.
 
virtual void startSuite (const std::string &suiteName)
 Start of test suite.
 
virtual void startCase (const std::string &suiteName, const std::string &caseName)
 Start of test case.
 
virtual void errorCase (const std::string &suiteName, const std::string &caseName, const std::string &casePart, const std::string &message)
 Unexpected error occurred during a part of the test case.
 
virtual void failCase (const std::string &suiteName, const std::string &caseName, const std::string &casePart, const TestFailure &failure)
 Test failure occurred during a part of the case.
 
virtual void exceptionCase (const std::string &suiteName, const std::string &caseName, const std::string &casePart, const std::exception &unexpected)
 Unexpected exception occurred during a part of the case.
 
virtual void endCase (const std::string &suiteName, const std::string &caseName, const bool pass)
 End of test case, with record pass or fail.
 
virtual void endSuite (const std::string &suiteName, const Count &count)
 End of test suite, with count of tests run and failed for that suite alone.
 
virtual void end (const Count &count)
 End of all testing, suitable to output.
 
- Public Member Functions inherited from JonTest::Logger
virtual ~Logger ()
 Destructor – does nothing.
 

Protected Attributes

std::ostream & out
 Stream to write to.
 
const bool verbose
 Simple level of verbosity: true for all events, false for critical.
 

Detailed Description

Stream-based Logger for events while running tests.

Test cases are counted as:

Examples
SimpleTest.cpp, and TestCaseOrder.cpp.

Definition at line 88 of file Logger.h.

Constructor & Destructor Documentation

◆ StreamLogger()

JonTest::StreamLogger::StreamLogger ( std::ostream &  out,
bool  verbose 
)

Construct the Stream Logger to write to out with the given verbosity.

Parameters
outStream to write to
verboseSimple level of verbosity: true for all events, false for critical

Definition at line 16 of file Logger.cpp.

◆ ~StreamLogger()

JonTest::StreamLogger::~StreamLogger ( )
virtual

Destructor – does nothing.

Definition at line 25 of file Logger.cpp.

Member Function Documentation

◆ end()

void JonTest::StreamLogger::end ( const Count count)
virtual

End of all testing, suitable to output.

Parameters
countCount of Test Cases run, and Test Cases failed

Implements JonTest::Logger.

Definition at line 117 of file Logger.cpp.

◆ endCase()

void JonTest::StreamLogger::endCase ( const std::string &  suiteName,
const std::string &  caseName,
const bool  pass 
)
virtual

End of test case, with record pass or fail.

Parameters
suiteNameName of test suite
caseNameName of test case
passtrue if passed, false if failed

Implements JonTest::Logger.

Definition at line 92 of file Logger.cpp.

◆ endSuite()

void JonTest::StreamLogger::endSuite ( const std::string &  suiteName,
const Count count 
)
virtual

End of test suite, with count of tests run and failed for that suite alone.

Parameters
suiteNameName of test suite
countCount of tests run and failed in this suite

Implements JonTest::Logger.

Definition at line 105 of file Logger.cpp.

◆ errorCase()

void JonTest::StreamLogger::errorCase ( const std::string &  suiteName,
const std::string &  caseName,
const std::string &  casePart,
const std::string &  message 
)
virtual

Unexpected error occurred during a part of the test case.

Parameters
suiteNameName of test suite
caseNameName of test case
casePartPart of the test case: setup, case, or teardown
messageError message

Implements JonTest::Logger.

Definition at line 59 of file Logger.cpp.

◆ exceptionCase()

void JonTest::StreamLogger::exceptionCase ( const std::string &  suiteName,
const std::string &  caseName,
const std::string &  casePart,
const std::exception &  unexpected 
)
virtual

Unexpected exception occurred during a part of the case.

Implements JonTest::Logger.

Definition at line 81 of file Logger.cpp.

◆ failCase()

void JonTest::StreamLogger::failCase ( const std::string &  suiteName,
const std::string &  caseName,
const std::string &  casePart,
const TestFailure failure 
)
virtual

Test failure occurred during a part of the case.

Parameters
suiteNameName of test suite
caseNameName of test case
casePartPart of the test case: setup, case, or teardown
failureTestFailure as recorded

Implements JonTest::Logger.

Definition at line 70 of file Logger.cpp.

◆ start()

void JonTest::StreamLogger::start ( )
virtual

Start of all testing.

Implements JonTest::Logger.

Definition at line 30 of file Logger.cpp.

◆ startCase()

void JonTest::StreamLogger::startCase ( const std::string &  suiteName,
const std::string &  caseName 
)
virtual

Start of test case.

Parameters
suiteNameName of test suite
caseNameName of test case

Implements JonTest::Logger.

Definition at line 48 of file Logger.cpp.

◆ startSuite()

void JonTest::StreamLogger::startSuite ( const std::string &  suiteName)
virtual

Start of test suite.

Parameters
suiteNameName of test suite

Implements JonTest::Logger.

Definition at line 38 of file Logger.cpp.

Member Data Documentation

◆ out

std::ostream& JonTest::StreamLogger::out
protected

Stream to write to.

Definition at line 92 of file Logger.h.

◆ verbose

const bool JonTest::StreamLogger::verbose
protected

Simple level of verbosity: true for all events, false for critical.

Definition at line 95 of file Logger.h.


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