Class CumulativeReporterBase

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class CumulativeReporterBase : public Catch::ReporterBase

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.

Subclassed by Catch::JunitReporter, Catch::SonarQubeReporter

Public Types

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

Public Functions

inline CumulativeReporterBase(ReporterConfig &&_config)
~CumulativeReporterBase() override
inline virtual void benchmarkPreparing(StringRef) override

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

inline virtual void benchmarkStarting(BenchmarkInfo const&) override

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

virtual void benchmarkEnded(BenchmarkStats<> const &benchmarkStats) override

Called with the benchmark results if benchmark successfully finishes.

inline virtual void benchmarkFailed(StringRef) override

Called if running the benchmarks fails for any reason.

inline virtual void noMatchingTestCases(StringRef) override

Called when no test cases match provided test spec.

inline virtual void reportInvalidTestSpec(StringRef) override

Called for all invalid test specs from the cli.

inline virtual void fatalErrorEncountered(StringRef) override

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

inline virtual void testRunStarting(TestRunInfo const&) override

Called once in a testing run before tests are started

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

inline virtual void testCaseStarting(TestCaseInfo const&) override

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

inline virtual void testCasePartialStarting(TestCaseInfo const&, uint64_t) override

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

virtual void sectionStarting(SectionInfo const &sectionInfo) override

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

inline virtual void assertionStarting(AssertionInfo const&) override

Called before assertion success/failure is evaluated.

virtual void assertionEnded(AssertionStats const &assertionStats) override

Called after assertion was fully evaluated.

virtual void sectionEnded(SectionStats const &sectionStats) override

Called after a SECTION has finished running.

inline virtual void testCasePartialEnded(TestCaseStats const&, uint64_t) override

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

virtual void testCaseEnded(TestCaseStats const &testCaseStats) override

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

virtual void testRunEnded(TestRunStats const &testRunStats) override

Called once after all tests in a testing run are finished

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

virtual void testRunEndedCumulative() = 0

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

inline virtual void skipTest(TestCaseInfo const&) override

Called with test cases that are skipped due to the test run aborting. NOT called for test cases that are explicitly skipped using the SKIP macro.

Deprecated - will be removed in the next major release.

Protected Attributes

bool m_shouldStoreSuccesfulAssertions = true

Should the cumulative base store the assertion expansion for successful 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.

template<typename T, typename ChildNodeT>
struct Node

Public Types

using ChildNodes = std::vector<Detail::unique_ptr<ChildNodeT>>

Public Functions

inline explicit Node(T const &_value)

Public Members

T value
ChildNodes children
struct SectionNode

Public Functions

inline explicit SectionNode(SectionStats const &_stats)
inline bool operator==(SectionNode const &other) const
bool hasAnyAssertions() const

Public Members

SectionStats stats
std::vector<Detail::unique_ptr<SectionNode>> childSections
std::vector<Detail::AssertionOrBenchmarkResult> assertionsAndBenchmarks
std::string stdOut
std::string stdErr