Horizon
Loading...
Searching...
No Matches
Catch::CumulativeReporterBase Class Referenceabstract

Utility base for reporters that need to handle all results at once. More...

#include <catch_amalgamated.hpp>

Inheritance diagram for Catch::CumulativeReporterBase:
Catch::ReporterBase Catch::IEventListener Catch::JunitReporter Catch::SonarQubeReporter

Classes

struct  Node
struct  SectionNode

Public Types

using TestCaseNode = Node<TestCaseStats, SectionNode>
using TestRunNode = Node<TestRunStats, TestCaseNode>

Public Member Functions

void benchmarkPreparing (StringRef) override
 Called when user-code is being probed before the actual benchmark runs.
void benchmarkStarting (BenchmarkInfo const &) override
 Called after probe but before the user-code is being benchmarked.
void benchmarkEnded (BenchmarkStats<> const &benchmarkStats) override
 Called with the benchmark results if benchmark successfully finishes.
void benchmarkFailed (StringRef) override
 Called if running the benchmarks fails for any reason.
void noMatchingTestCases (StringRef) override
 Called when no test cases match provided test spec.
void reportInvalidTestSpec (StringRef) override
 Called for all invalid test specs from the cli.
void fatalErrorEncountered (StringRef) override
 Called if a fatal error (signal/structured exception) occured.
void testRunStarting (TestRunInfo const &) override
 Called once in a testing run before tests are started.
void testCaseStarting (TestCaseInfo const &) override
 Called once for each TEST_CASE, no matter how many times it is entered.
void testCasePartialStarting (TestCaseInfo const &, uint64_t) override
 Called every time a TEST_CASE is entered, including repeats (due to sections).
void sectionStarting (SectionInfo const &sectionInfo) override
 Called when a SECTION is being entered. Not called for skipped sections.
void assertionStarting (AssertionInfo const &) override
 Called before assertion success/failure is evaluated.
void assertionEnded (AssertionStats const &assertionStats) override
 Called after assertion was fully evaluated.
void sectionEnded (SectionStats const &sectionStats) override
 Called after a SECTION has finished running.
void testCasePartialEnded (TestCaseStats const &, uint64_t) override
 Called every time a TEST_CASE is entered, including repeats (due to sections).
void testCaseEnded (TestCaseStats const &testCaseStats) override
 Called once for each TEST_CASE, no matter how many times it is entered.
void testRunEnded (TestRunStats const &testRunStats) override
 Called once after all tests in a testing run are finished.
virtual void testRunEndedCumulative ()=0
 Customization point: called after last test finishes (testRunEnded has been handled).
void skipTest (TestCaseInfo const &) override
 Called with test cases that are skipped due to the test run aborting.
 ReporterBase (ReporterConfig &&config)
Public Member Functions inherited from Catch::ReporterBase
 ReporterBase (ReporterConfig &&config)
void listReporters (std::vector< ReporterDescription > const &descriptions) override
 Provides a simple default listing of reporters.
void listListeners (std::vector< ListenerDescription > const &descriptions) override
 Provides a simple default listing of listeners.
void listTests (std::vector< TestCaseHandle > const &tests) override
 Provides a simple default listing of tests.
void listTags (std::vector< TagInfo > const &tags) override
 Provides a simple default listing of tags.
Public Member Functions inherited from Catch::IEventListener
 IEventListener (IConfig const *config)
ReporterPreferences const & getPreferences () const

Protected Attributes

bool m_shouldStoreSuccesfulAssertions = true
 Should the cumulative base store the assertion expansion for succesful assertions?
bool m_shouldStoreFailedAssertions = true
 Should the cumulative base store the assertion expansion for failed assertions?
Detail::unique_ptr< TestRunNode > m_testRun
 The root node of the test run tree.
Protected Attributes inherited from Catch::ReporterBase
Detail::unique_ptr< IStreamm_wrapped_stream
 The stream wrapper as passed to us by outside code.
std::ostream & m_stream
Detail::unique_ptr< ColourImplm_colour
 Colour implementation this reporter was configured for.
std::map< std::string, std::string > m_customOptions
 The custom reporter options user passed down to the reporter.
Protected Attributes inherited from Catch::IEventListener
ReporterPreferences m_preferences
 Derived classes can set up their preferences here.
IConfig const * m_config
 The test run's config as filled in from CLI and defaults.

Detailed Description

Utility base for reporters that need to handle all results at once.

It stores tree of all test cases, sections and assertions, and after the test run is finished, calls into testRunEndedCumulative to pass the control to the deriving class.

If you are deriving from this class and override any testing related member functions, you should first call into the base's implementation to avoid breaking the tree construction.

Due to the way this base functions, it has to expand assertions up-front, even if they are later unused (e.g. because the deriving reporter does not report successful assertions, or because the deriving reporter does not use assertion expansion at all). Derived classes can use two customization points, m_shouldStoreSuccesfulAssertions and m_shouldStoreFailedAssertions, to disable the expansion and gain extra performance. Accessing the assertion expansions if it wasn't stored is UB.

Member Function Documentation

◆ assertionEnded()

void Catch::CumulativeReporterBase::assertionEnded ( AssertionStats const & assertionStats)
overridevirtual

Called after assertion was fully evaluated.

Implements Catch::IEventListener.

Reimplemented in Catch::JunitReporter.

◆ assertionStarting()

void Catch::CumulativeReporterBase::assertionStarting ( AssertionInfo const & assertionInfo)
inlineoverridevirtual

Called before assertion success/failure is evaluated.

Implements Catch::IEventListener.

◆ benchmarkEnded()

void Catch::CumulativeReporterBase::benchmarkEnded ( BenchmarkStats<> const & benchmarkStats)
overridevirtual

Called with the benchmark results if benchmark successfully finishes.

Implements Catch::IEventListener.

◆ benchmarkFailed()

void Catch::CumulativeReporterBase::benchmarkFailed ( StringRef benchmarkName)
inlineoverridevirtual

Called if running the benchmarks fails for any reason.

Implements Catch::IEventListener.

◆ benchmarkPreparing()

void Catch::CumulativeReporterBase::benchmarkPreparing ( StringRef benchmarkName)
inlineoverridevirtual

Called when user-code is being probed before the actual benchmark runs.

Implements Catch::IEventListener.

◆ benchmarkStarting()

void Catch::CumulativeReporterBase::benchmarkStarting ( BenchmarkInfo const & benchmarkInfo)
inlineoverridevirtual

Called after probe but before the user-code is being benchmarked.

Implements Catch::IEventListener.

◆ fatalErrorEncountered()

void Catch::CumulativeReporterBase::fatalErrorEncountered ( StringRef error)
inlineoverridevirtual

Called if a fatal error (signal/structured exception) occured.

Implements Catch::IEventListener.

◆ noMatchingTestCases()

void Catch::CumulativeReporterBase::noMatchingTestCases ( StringRef unmatchedSpec)
inlineoverridevirtual

Called when no test cases match provided test spec.

Implements Catch::IEventListener.

◆ reportInvalidTestSpec()

void Catch::CumulativeReporterBase::reportInvalidTestSpec ( StringRef invalidArgument)
inlineoverridevirtual

Called for all invalid test specs from the cli.

Implements Catch::IEventListener.

◆ sectionEnded()

void Catch::CumulativeReporterBase::sectionEnded ( SectionStats const & sectionStats)
overridevirtual

Called after a SECTION has finished running.

Implements Catch::IEventListener.

◆ sectionStarting()

void Catch::CumulativeReporterBase::sectionStarting ( SectionInfo const & sectionInfo)
overridevirtual

Called when a SECTION is being entered. Not called for skipped sections.

Implements Catch::IEventListener.

◆ skipTest()

void Catch::CumulativeReporterBase::skipTest ( TestCaseInfo const & testInfo)
inlineoverridevirtual

Called with test cases that are skipped due to the test run aborting.

Implements Catch::IEventListener.

◆ testCaseEnded()

void Catch::CumulativeReporterBase::testCaseEnded ( TestCaseStats const & testCaseStats)
overridevirtual

Called once for each TEST_CASE, no matter how many times it is entered.

Implements Catch::IEventListener.

Reimplemented in Catch::JunitReporter.

◆ testCasePartialEnded()

void Catch::CumulativeReporterBase::testCasePartialEnded ( TestCaseStats const & testCaseStats,
uint64_t partNumber )
inlineoverridevirtual

Called every time a TEST_CASE is entered, including repeats (due to sections).

Implements Catch::IEventListener.

◆ testCasePartialStarting()

void Catch::CumulativeReporterBase::testCasePartialStarting ( TestCaseInfo const & testInfo,
uint64_t partNumber )
inlineoverridevirtual

Called every time a TEST_CASE is entered, including repeats (due to sections).

Implements Catch::IEventListener.

◆ testCaseStarting()

void Catch::CumulativeReporterBase::testCaseStarting ( TestCaseInfo const & testInfo)
inlineoverridevirtual

Called once for each TEST_CASE, no matter how many times it is entered.

Implements Catch::IEventListener.

Reimplemented in Catch::JunitReporter.

◆ testRunEnded()

void Catch::CumulativeReporterBase::testRunEnded ( TestRunStats const & testRunStats)
overridevirtual

Called once after all tests in a testing run are finished.

Not called if tests weren't run (e.g. only listings happened)

Implements Catch::IEventListener.

◆ testRunEndedCumulative()

virtual void Catch::CumulativeReporterBase::testRunEndedCumulative ( )
pure virtual

Customization point: called after last test finishes (testRunEnded has been handled).

Implemented in Catch::JunitReporter, and Catch::SonarQubeReporter.

◆ testRunStarting()

void Catch::CumulativeReporterBase::testRunStarting ( TestRunInfo const & testRunInfo)
inlineoverridevirtual

Called once in a testing run before tests are started.

Not called if tests won't be run (e.g. only listing will happen)

Implements Catch::IEventListener.

Reimplemented in Catch::JunitReporter, and Catch::SonarQubeReporter.


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