Tweaked how failedButOk assertions are recorded

- fixes issue where sections in !shouldfail or !mayfail test cases that have failing assertions where marked as failed instead of failedButOk
This commit is contained in:
Phil Nash 2017-08-25 11:33:29 +01:00
parent b6e7c9bd7a
commit 8e8c0c1675
2 changed files with 6 additions and 9 deletions

View File

@ -166,7 +166,10 @@ namespace Catch {
m_totals.assertions.passed++;
}
else if( !result.isOk() ) {
m_totals.assertions.failed++;
if( m_activeTestCase->getTestCaseInfo().okToFail() )
m_totals.assertions.failedButOk++;
else
m_totals.assertions.failed++;
}
// We have no use for the return value (whether messages should be cleared), because messages were made scoped
@ -355,12 +358,6 @@ namespace Catch {
Counts assertions = m_totals.assertions - prevAssertions;
bool missingAssertions = testForMissingAssertions( assertions );
if( testCaseInfo.okToFail() ) {
std::swap( assertions.failedButOk, assertions.failed );
m_totals.assertions.failed -= assertions.failedButOk;
m_totals.assertions.failedButOk += assertions.failedButOk;
}
SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions );
m_reporter->sectionEnded( testCaseSectionStats );
}

View File

@ -12,7 +12,7 @@
<Exception filename="projects/<exe-name>/ExceptionTests.cpp" >
expected exception
</Exception>
<OverallResults successes="0" failures="1" expectedFailures="0"/>
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<Section name="inside REQUIRE_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" >
<Info>
@ -29,7 +29,7 @@
expected exception
</Exception>
</Expression>
<OverallResults successes="0" failures="1" expectedFailures="0"/>
<OverallResults successes="0" failures="0" expectedFailures="1"/>
</Section>
<Section name="inside REQUIRE_THROWS" filename="projects/<exe-name>/ExceptionTests.cpp" >
<Info>