mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-04 05:09:53 +01:00
Tidied up reporting of missing assertions in test cases
- also removed basic reporter from approval test
This commit is contained in:
parent
801672b962
commit
b80280f428
@ -267,6 +267,7 @@ namespace Catch {
|
|||||||
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
|
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
|
||||||
SectionInfo testCaseSection( testCaseInfo.name, testCaseInfo.description, testCaseInfo.lineInfo );
|
SectionInfo testCaseSection( testCaseInfo.name, testCaseInfo.description, testCaseInfo.lineInfo );
|
||||||
m_reporter->sectionStarting( testCaseSection );
|
m_reporter->sectionStarting( testCaseSection );
|
||||||
|
Counts prevAssertions = m_totals.assertions;
|
||||||
try {
|
try {
|
||||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
|
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
|
||||||
TestCaseTracker::Guard guard( *m_testCaseTracker );
|
TestCaseTracker::Guard guard( *m_testCaseTracker );
|
||||||
@ -297,7 +298,20 @@ namespace Catch {
|
|||||||
sectionEnded( it->info, it->prevAssertions );
|
sectionEnded( it->info, it->prevAssertions );
|
||||||
m_unfinishedSections.clear();
|
m_unfinishedSections.clear();
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
SectionStats testCaseSectionStats( testCaseSection, Counts(), 0 ); // !TBD
|
|
||||||
|
Counts assertions = m_totals.assertions - prevAssertions;
|
||||||
|
// !TBD?
|
||||||
|
bool missingAssertions = false;
|
||||||
|
if( assertions.total() == 0 &&
|
||||||
|
m_config->warnAboutMissingAssertions() &&
|
||||||
|
!m_testCaseTracker->currentSectionHasChildren() ) {
|
||||||
|
m_totals.assertions.failed++;
|
||||||
|
assertions.failed++;
|
||||||
|
missingAssertions = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SectionStats testCaseSectionStats( testCaseSection, assertions, missingAssertions );
|
||||||
m_reporter->sectionEnded( testCaseSectionStats );
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,11 @@ namespace Catch {
|
|||||||
if( _sectionStats.missingAssertions ) {
|
if( _sectionStats.missingAssertions ) {
|
||||||
lazyPrint();
|
lazyPrint();
|
||||||
Colour colour( Colour::ResultError );
|
Colour colour( Colour::ResultError );
|
||||||
stream << "\nNo assertions in section, '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
|
if( currentSectionInfo->parent )
|
||||||
|
stream << "\nNo assertions in section";
|
||||||
|
else
|
||||||
|
stream << "\nNo assertions in test case";
|
||||||
|
stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
|
||||||
}
|
}
|
||||||
m_headerPrinted = false;
|
m_headerPrinted = false;
|
||||||
StreamingReporterBase::sectionEnded( _sectionStats );
|
StreamingReporterBase::sectionEnded( _sectionStats );
|
||||||
@ -262,6 +266,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
void printTestCaseAndSectionHeader() {
|
void printTestCaseAndSectionHeader() {
|
||||||
printOpenHeader( unusedTestCaseInfo->name );
|
printOpenHeader( unusedTestCaseInfo->name );
|
||||||
|
assert( currentSectionInfo );
|
||||||
if( currentSectionInfo ) {
|
if( currentSectionInfo ) {
|
||||||
Colour colourGuard( Colour::Headers );
|
Colour colourGuard( Colour::Headers );
|
||||||
std::vector<ThreadedSectionInfo*> sections;
|
std::vector<ThreadedSectionInfo*> sections;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -26,8 +26,6 @@ subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "console"
|
|||||||
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "console", "-a", "4" ], stdout=f, stderr=f )
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "console", "-a", "4" ], stdout=f, stderr=f )
|
||||||
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "junit" ], stdout=f, stderr=f )
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "junit" ], stdout=f, stderr=f )
|
||||||
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "xml" ], stdout=f, stderr=f )
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "xml" ], stdout=f, stderr=f )
|
||||||
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "basic" ], stdout=f, stderr=f )
|
|
||||||
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "basic", "-a", "4" ], stdout=f, stderr=f )
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
rawFile = open( rawResultsPath, 'r' )
|
rawFile = open( rawResultsPath, 'r' )
|
||||||
|
Loading…
Reference in New Issue
Block a user