mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01: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:
parent
db48a6dfda
commit
5d248c98bf
@ -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 {
|
||||
|
@ -196,12 +196,12 @@
|
||||
[Running: ./succeeding/conditions/ptr]
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:285: p == __null succeeded for: __null == 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:286: p == pNULL succeeded for: __null == __null
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:291: p != __null succeeded for: 0x7fff54a840d8 != 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:294: cp != __null succeeded for: 0x7fff54a840d8 != 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:297: cpc != __null succeeded for: 0x7fff54a840d8 != 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:291: p != __null succeeded for: 0x7fff5c6b3078 != 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:294: cp != __null succeeded for: 0x7fff5c6b3078 != 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:297: cpc != __null succeeded for: 0x7fff5c6b3078 != 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:299: returnsNull() == __null succeeded for: {null string} == 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:300: returnsConstNull() == __null succeeded for: {null string} == 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:302: __null != p succeeded for: 0 != 0x7fff54a840d8
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:302: __null != p succeeded for: 0 != 0x7fff5c6b3078
|
||||
[Finished: './succeeding/conditions/ptr' All tests passed (8 assertions in 1 test case)]
|
||||
|
||||
[Running: ./succeeding/conditions/not]
|
||||
@ -475,10 +475,7 @@ No assertions in section, 'the section2'
|
||||
|
||||
[Running: ./succeeding/message]
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/MessageTests.cpp:14: [warning: this is a warning]
|
||||
|
||||
No assertions in test case, './succeeding/message'
|
||||
|
||||
[Finished: './succeeding/message' 1 test case failed (1 assertion failed)]
|
||||
[Finished: './succeeding/message' No tests ran]
|
||||
|
||||
[Running: ./failing/message/info/1]
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/MessageTests.cpp:19: [info: this message should be logged]
|
||||
@ -1281,7 +1278,7 @@ No assertions in test case, './inprogress/failing/Tricky/compound lhs'
|
||||
[Finished: './inprogress/failing/Tricky/compound lhs' 1 test case failed (1 assertion failed)]
|
||||
|
||||
[Running: ./failing/Tricky/non streamable type]
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:95: &o1 == &o2 failed for: 0x7fff54a848b8 == 0x7fff54a848b0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:95: &o1 == &o2 failed for: 0x7fff5c6b3858 == 0x7fff5c6b3850
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:96: o1 == o2 failed for: {?} == {?}
|
||||
[Finished: './failing/Tricky/non streamable type' 1 test case failed (All 2 assertions failed)]
|
||||
|
||||
@ -1307,7 +1304,7 @@ No assertions in test case, './inprogress/failing/Tricky/compound lhs'
|
||||
[Finished: './succeeding/enum/bits' All tests passed (1 assertion in 1 test case)]
|
||||
|
||||
[Running: ./succeeding/boolean member]
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:239: obj.prop != __null succeeded for: 0x7fff54a848b0 != 0
|
||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:239: obj.prop != __null succeeded for: 0x7fff5c6b3850 != 0
|
||||
[Finished: './succeeding/boolean member' All tests passed (1 assertion in 1 test case)]
|
||||
|
||||
[Running: ./succeeding/unimplemented static bool]
|
||||
@ -1354,8 +1351,8 @@ No assertions in test case, './inprogress/failing/Tricky/compound lhs'
|
||||
[End of section: 'This stuff exists' 1 assertion passed]
|
||||
|
||||
[Finished: 'scenario name' All tests passed (1 assertion in 1 test case)]
|
||||
[End of group: '~dummy'. 45 of 97 test cases failed (103 of 613 assertions failed)]
|
||||
[End of group: '~dummy'. 44 of 97 test cases failed (102 of 612 assertions failed)]
|
||||
|
||||
|
||||
[Testing completed. 45 of 97 test cases failed (103 of 613 assertions failed)]
|
||||
[Testing completed. 44 of 97 test cases failed (102 of 612 assertions failed)]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user