mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Tweaks to summary counts in console reporter
This commit is contained in:
@@ -36,12 +36,10 @@ namespace Catch {
|
||||
void lazyPrintGroupInfo() {
|
||||
if( !unusedGroupInfo->name.empty() )
|
||||
stream << "[Group: '" << unusedGroupInfo->name << "']" << std::endl;
|
||||
// stream << "[Started group: '" << unusedGroupInfo->name << "']" << std::endl;
|
||||
unusedGroupInfo.reset();
|
||||
}
|
||||
void lazyPrintTestCaseInfo() {
|
||||
stream << "[Test case: '" << unusedTestCaseInfo->name << "']" << std::endl;
|
||||
// stream << "[Running: " << unusedTestCaseInfo->name << "]" << std::endl;
|
||||
unusedTestCaseInfo.reset();
|
||||
}
|
||||
|
||||
@@ -54,7 +52,6 @@ namespace Catch {
|
||||
|
||||
typedef std::vector<ThreadedSectionInfo*>::const_reverse_iterator It;
|
||||
for( It it = sections.rbegin(), itEnd = sections.rend(); it != itEnd; ++it ) {
|
||||
// stream << "[Started section: " << "'" + (*it)->name + "'" << "]" << std::endl;
|
||||
stream << "[Section: " << "'" + (*it)->name + "'" << "]" << std::endl;
|
||||
(*it)->printed = true;
|
||||
}
|
||||
@@ -195,29 +192,49 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
void printAssertionCounts( std::string const& label, Counts const& counts, std::string const& allPrefix = "All " ) {
|
||||
if( counts.passed )
|
||||
stream << counts.failed << " of " << counts.total() << " " << label << "s failed";
|
||||
else
|
||||
stream << ( counts.failed > 1 ? allPrefix : "" ) << pluralise( counts.failed, label ) << " failed";
|
||||
void printAssertionCounts( std::string const& label, Counts const& counts ) {
|
||||
if( counts.total() == 1 ) {
|
||||
stream << "1 " << label << " - ";
|
||||
if( counts.failed )
|
||||
stream << "failed";
|
||||
else
|
||||
stream << "passed";
|
||||
}
|
||||
else {
|
||||
stream << counts.total() << " " << label << "s ";
|
||||
if( counts.passed ) {
|
||||
if( counts.failed )
|
||||
stream << "- " << counts.failed << " failed";
|
||||
else if( counts.passed == 2 )
|
||||
stream << "- both passed";
|
||||
else
|
||||
stream << "- all passed";
|
||||
}
|
||||
else {
|
||||
if( counts.failed == 2 )
|
||||
stream << "- both failed";
|
||||
else
|
||||
stream << "- all failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void printTotals( const Totals& totals, const std::string& allPrefix = "All " ) {
|
||||
void printTotals( const Totals& totals ) {
|
||||
if( totals.assertions.total() == 0 ) {
|
||||
stream << "No tests ran";
|
||||
}
|
||||
else if( totals.assertions.failed ) {
|
||||
TextColour colour( TextColour::ResultError );
|
||||
printAssertionCounts( "test case", totals.testCases, allPrefix );
|
||||
printAssertionCounts( "test case", totals.testCases );
|
||||
if( totals.testCases.failed > 0 ) {
|
||||
stream << " (";
|
||||
printAssertionCounts( "assertion", totals.assertions, allPrefix );
|
||||
printAssertionCounts( "assertion", totals.assertions );
|
||||
stream << ")";
|
||||
}
|
||||
}
|
||||
else {
|
||||
TextColour colour( TextColour::ResultSuccess );
|
||||
stream << allPrefix << "tests passed ("
|
||||
stream << "All tests passed ("
|
||||
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
|
||||
<< pluralise( totals.testCases.passed, "test case" ) << ")";
|
||||
}
|
||||
@@ -231,7 +248,6 @@ namespace Catch {
|
||||
}
|
||||
if( currentSectionInfo && currentSectionInfo->printed ) {
|
||||
stream << "[Summary for section '" << _sectionStats->sectionInfo.name << "': ";
|
||||
// stream << "[End of section: '" << _sectionStats->sectionInfo.name << "' ";
|
||||
Counts const& assertions = _sectionStats->assertions;
|
||||
if( assertions.failed ) {
|
||||
TextColour colour( TextColour::ResultError );
|
||||
@@ -254,7 +270,6 @@ namespace Catch {
|
||||
}
|
||||
if( !unusedTestCaseInfo ) {
|
||||
stream << "[Summary for test case '" << _testCaseStats->testInfo.name << "': ";
|
||||
// stream << "[Finished: '" << _testCaseStats->testInfo.name << "' ";
|
||||
printTotals( _testCaseStats->totals );
|
||||
stream << "]\n" << std::endl;
|
||||
}
|
||||
@@ -263,7 +278,6 @@ namespace Catch {
|
||||
virtual void testGroupEnded( Ptr<TestGroupStats const> const& _testGroupStats ) {
|
||||
if( !unusedGroupInfo ) {
|
||||
stream << "[Summary for group '" << _testGroupStats->groupInfo.name << "': ";
|
||||
// stream << "[End of group '" << _testGroupStats->groupInfo.name << "'. ";
|
||||
printTotals( _testGroupStats->totals );
|
||||
stream << "]\n" << std::endl;
|
||||
}
|
||||
@@ -272,7 +286,6 @@ namespace Catch {
|
||||
virtual void testRunEnded( Ptr<TestRunStats const> const& _testRunStats ) {
|
||||
if( !unusedTestCaseInfo ) {
|
||||
stream << "[Summary for '" << _testRunStats->runInfo.name << "': ";
|
||||
// stream << "[Testing completed. ";
|
||||
printTotals( _testRunStats->totals );
|
||||
stream << "]\n" << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user