mirror of
https://github.com/catchorg/Catch2.git
synced 2025-01-22 08:43:29 +01:00
Add test case stats functionality and test case name priority output
This commit is contained in:
parent
914aeecfe2
commit
12195c836a
@ -205,6 +205,8 @@ namespace Catch {
|
|||||||
int Config::abortAfter() const { return m_data.abortAfter; }
|
int Config::abortAfter() const { return m_data.abortAfter; }
|
||||||
bool Config::showInvisibles() const { return m_data.showInvisibles; }
|
bool Config::showInvisibles() const { return m_data.showInvisibles; }
|
||||||
Verbosity Config::verbosity() const { return m_data.verbosity; }
|
Verbosity Config::verbosity() const { return m_data.verbosity; }
|
||||||
|
bool Config::outputTestCaseNameFirst() const { return m_data.outputTestCaseNameFirst; }
|
||||||
|
bool Config::outputTestCaseStats() const { return m_data.outputTestCaseStats; }
|
||||||
|
|
||||||
bool Config::skipBenchmarks() const { return m_data.skipBenchmarks; }
|
bool Config::skipBenchmarks() const { return m_data.skipBenchmarks; }
|
||||||
bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; }
|
bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; }
|
||||||
|
@ -58,6 +58,8 @@ namespace Catch {
|
|||||||
bool filenamesAsTags = false;
|
bool filenamesAsTags = false;
|
||||||
bool libIdentify = false;
|
bool libIdentify = false;
|
||||||
bool allowZeroTests = false;
|
bool allowZeroTests = false;
|
||||||
|
bool outputTestCaseNameFirst = false;
|
||||||
|
bool outputTestCaseStats = false;
|
||||||
|
|
||||||
int abortAfter = -1;
|
int abortAfter = -1;
|
||||||
uint32_t rngSeed = generateRandomSeed(GenerateFrom::Default);
|
uint32_t rngSeed = generateRandomSeed(GenerateFrom::Default);
|
||||||
@ -132,6 +134,8 @@ namespace Catch {
|
|||||||
int abortAfter() const override;
|
int abortAfter() const override;
|
||||||
bool showInvisibles() const override;
|
bool showInvisibles() const override;
|
||||||
Verbosity verbosity() const override;
|
Verbosity verbosity() const override;
|
||||||
|
bool outputTestCaseNameFirst() const override;
|
||||||
|
bool outputTestCaseStats() const override;
|
||||||
bool skipBenchmarks() const override;
|
bool skipBenchmarks() const override;
|
||||||
bool benchmarkNoAnalysis() const override;
|
bool benchmarkNoAnalysis() const override;
|
||||||
unsigned int benchmarkSamples() const override;
|
unsigned int benchmarkSamples() const override;
|
||||||
|
@ -87,6 +87,8 @@ namespace Catch {
|
|||||||
virtual ColourMode defaultColourMode() const = 0;
|
virtual ColourMode defaultColourMode() const = 0;
|
||||||
virtual std::vector<std::string> const& getSectionsToRun() const = 0;
|
virtual std::vector<std::string> const& getSectionsToRun() const = 0;
|
||||||
virtual Verbosity verbosity() const = 0;
|
virtual Verbosity verbosity() const = 0;
|
||||||
|
virtual bool outputTestCaseNameFirst() const = 0;
|
||||||
|
virtual bool outputTestCaseStats() const = 0;
|
||||||
|
|
||||||
virtual bool skipBenchmarks() const = 0;
|
virtual bool skipBenchmarks() const = 0;
|
||||||
virtual bool benchmarkNoAnalysis() const = 0;
|
virtual bool benchmarkNoAnalysis() const = 0;
|
||||||
|
@ -251,6 +251,12 @@ namespace Catch {
|
|||||||
| Opt( setVerbosity, "quiet|normal|high" )
|
| Opt( setVerbosity, "quiet|normal|high" )
|
||||||
["-v"]["--verbosity"]
|
["-v"]["--verbosity"]
|
||||||
( "set output verbosity" )
|
( "set output verbosity" )
|
||||||
|
| Opt( config.outputTestCaseNameFirst)
|
||||||
|
["--output-test-case-name-first"]
|
||||||
|
( "test case name will be printed before the test is run" )
|
||||||
|
| Opt( config.outputTestCaseStats)
|
||||||
|
["--output-test-case-stats"]
|
||||||
|
( "prints assertion stat data of the test case run" )
|
||||||
| Opt( config.listTests )
|
| Opt( config.listTests )
|
||||||
["--list-tests"]
|
["--list-tests"]
|
||||||
( "list all/matching test cases" )
|
( "list all/matching test cases" )
|
||||||
|
@ -512,11 +512,31 @@ void ConsoleReporter::benchmarkFailed( StringRef error ) {
|
|||||||
<< ColumnBreak() << RowBreak();
|
<< ColumnBreak() << RowBreak();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConsoleReporter::testCaseStarting( TestCaseInfo const& testInfo ) {
|
||||||
|
StreamingReporterBase::testCaseStarting( testInfo );
|
||||||
|
|
||||||
|
if ( m_config->outputTestCaseNameFirst() ) {
|
||||||
|
m_stream << testInfo.name << ":\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) {
|
void ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) {
|
||||||
m_tablePrinter->close();
|
m_tablePrinter->close();
|
||||||
StreamingReporterBase::testCaseEnded(_testCaseStats);
|
StreamingReporterBase::testCaseEnded(_testCaseStats);
|
||||||
m_headerPrinted = false;
|
m_headerPrinted = false;
|
||||||
|
|
||||||
|
if ( !_testCaseStats.aborting && m_config->outputTestCaseStats() ) {
|
||||||
|
if (!m_config->outputTestCaseNameFirst())
|
||||||
|
{
|
||||||
|
m_stream << _testCaseStats.testInfo->name << ": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_stream << _testCaseStats.totals.assertions.passed << " passed "
|
||||||
|
<< _testCaseStats.totals.assertions.failed << " failed "
|
||||||
|
<< _testCaseStats.totals.assertions.skipped << " skipped\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) {
|
void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) {
|
||||||
printTotalsDivider(_testRunStats.totals);
|
printTotalsDivider(_testRunStats.totals);
|
||||||
printTestRunTotals( m_stream, *m_colour, _testRunStats.totals );
|
printTestRunTotals( m_stream, *m_colour, _testRunStats.totals );
|
||||||
|
@ -38,6 +38,7 @@ namespace Catch {
|
|||||||
void benchmarkEnded(BenchmarkStats<> const& stats) override;
|
void benchmarkEnded(BenchmarkStats<> const& stats) override;
|
||||||
void benchmarkFailed( StringRef error ) override;
|
void benchmarkFailed( StringRef error ) override;
|
||||||
|
|
||||||
|
void testCaseStarting( TestCaseInfo const& testInfo ) override;
|
||||||
void testCaseEnded(TestCaseStats const& _testCaseStats) override;
|
void testCaseEnded(TestCaseStats const& _testCaseStats) override;
|
||||||
void testRunEnded(TestRunStats const& _testRunStats) override;
|
void testRunEnded(TestRunStats const& _testRunStats) override;
|
||||||
void testRunStarting(TestRunInfo const& _testRunInfo) override;
|
void testRunStarting(TestRunInfo const& _testRunInfo) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user