Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2013-07-26 19:19:44 +0100
committerPhil Nash2013-07-26 19:19:44 +0100
commitb80280f42889425d15062a4e947bd2de1aaf38f3 (patch)
tree7d5f00d86b3580890d2571328904511211f134f9 /include
parent801672b96228bfc60f7112c9a8b33c86e1d6c5ba (diff)
downloadcatch3-b80280f42889425d15062a4e947bd2de1aaf38f3.tar.gz
Tidied up reporting of missing assertions in test cases
- also removed basic reporter from approval test
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_runner_impl.hpp16
-rw-r--r--include/reporters/catch_reporter_console.hpp7
2 files changed, 21 insertions, 2 deletions
diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp
index cf971539..589003c7 100644
--- a/include/internal/catch_runner_impl.hpp
+++ b/include/internal/catch_runner_impl.hpp
@@ -267,6 +267,7 @@ namespace Catch {
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
SectionInfo testCaseSection( testCaseInfo.name, testCaseInfo.description, testCaseInfo.lineInfo );
m_reporter->sectionStarting( testCaseSection );
+ Counts prevAssertions = m_totals.assertions;
try {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
TestCaseTracker::Guard guard( *m_testCaseTracker );
@@ -297,7 +298,20 @@ namespace Catch {
sectionEnded( it->info, it->prevAssertions );
m_unfinishedSections.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 );
}
diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp
index 87a32500..af3523de 100644
--- a/include/reporters/catch_reporter_console.hpp
+++ b/include/reporters/catch_reporter_console.hpp
@@ -62,7 +62,11 @@ namespace Catch {
if( _sectionStats.missingAssertions ) {
lazyPrint();
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;
StreamingReporterBase::sectionEnded( _sectionStats );
@@ -262,6 +266,7 @@ namespace Catch {
}
void printTestCaseAndSectionHeader() {
printOpenHeader( unusedTestCaseInfo->name );
+ assert( currentSectionInfo );
if( currentSectionInfo ) {
Colour colourGuard( Colour::Headers );
std::vector<ThreadedSectionInfo*> sections;