mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Moved code that detects absence of assertions closer to where end of test case is reported (ready for merging).
Also now considers info macros when warning (i.e. an empty test case with an INFO() will not warn).
This commit is contained in:
@@ -115,12 +115,22 @@ namespace Catch {
|
||||
}
|
||||
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
|
||||
|
||||
Totals deltaTotals = m_totals.delta( prevTotals );
|
||||
if( deltaTotals.assertions.total() == 0 &&
|
||||
deltaTotals.assertions.info == 0 &&
|
||||
( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) ) {
|
||||
m_totals.assertions.failed++;
|
||||
deltaTotals = m_totals.delta( prevTotals );
|
||||
m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCaseInfo().getName() );
|
||||
}
|
||||
m_totals.testCases += deltaTotals.testCases;
|
||||
|
||||
m_reporter->EndTestCase( testInfo, deltaTotals, redirectedCout, redirectedCerr );
|
||||
|
||||
|
||||
delete m_runningTest;
|
||||
m_runningTest = NULL;
|
||||
|
||||
Totals deltaTotals = m_totals.delta( prevTotals );
|
||||
m_totals.testCases += deltaTotals.testCases;
|
||||
m_reporter->EndTestCase( testInfo, deltaTotals, redirectedCout, redirectedCerr );
|
||||
return deltaTotals;
|
||||
}
|
||||
|
||||
@@ -158,7 +168,10 @@ namespace Catch {
|
||||
}
|
||||
|
||||
if( result.getResultType() == ResultWas::Info )
|
||||
{
|
||||
m_assertionResults.push_back( result );
|
||||
m_totals.assertions.info++;
|
||||
}
|
||||
else
|
||||
m_reporter->Result( result );
|
||||
|
||||
@@ -252,7 +265,6 @@ namespace Catch {
|
||||
try {
|
||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo(), "", ResultDisposition::Normal );
|
||||
m_runningTest->reset();
|
||||
Counts prevAssertions = m_totals.assertions;
|
||||
if( m_reporter->shouldRedirectStdout() ) {
|
||||
StreamRedirect coutRedir( std::cout, redirectedCout );
|
||||
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
|
||||
@@ -261,13 +273,6 @@ namespace Catch {
|
||||
else {
|
||||
m_runningTest->getTestCaseInfo().invoke();
|
||||
}
|
||||
Counts assertions = m_totals.assertions - prevAssertions;
|
||||
if( assertions.total() == 0 &&
|
||||
( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) &&
|
||||
!m_runningTest->hasSections() ) {
|
||||
m_totals.assertions.failed++;
|
||||
m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCaseInfo().getName() );
|
||||
}
|
||||
m_runningTest->ranToCompletion();
|
||||
}
|
||||
catch( TestFailureException& ) {
|
||||
|
@@ -13,17 +13,19 @@
|
||||
namespace Catch {
|
||||
|
||||
struct Counts {
|
||||
Counts() : passed( 0 ), failed( 0 ) {}
|
||||
Counts() : passed( 0 ), failed( 0 ), info( 0 ) {}
|
||||
|
||||
Counts operator - ( const Counts& other ) const {
|
||||
Counts diff;
|
||||
diff.passed = passed - other.passed;
|
||||
diff.failed = failed - other.failed;
|
||||
diff.info = info - other.info;
|
||||
return diff;
|
||||
}
|
||||
Counts& operator += ( const Counts& other ) {
|
||||
passed += other.passed;
|
||||
failed += other.failed;
|
||||
info += other.info;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -33,6 +35,7 @@ namespace Catch {
|
||||
|
||||
std::size_t passed;
|
||||
std::size_t failed;
|
||||
std::size_t info;
|
||||
};
|
||||
|
||||
struct Totals {
|
||||
|
Reference in New Issue
Block a user