Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

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
Commit
b1d008579604b08217857863c8276bcfc6865c67
Author
Phil Nash ·
Parents
071f49b12b62

Files · Download .tar.gz

Changes

 include/internal/catch_run_context.cpp          | 12 ++++--------
 projects/SelfTest/Baselines/xml.sw.approved.txt |  4 ++--
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index d29ef54d..d5b69ae5 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -112,7 +112,10 @@ namespace Catch {
         if (result.getResultType() == ResultWas::Ok) {
             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
@@ -297,13 +300,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);
     }
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 8f52326e..61870985 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -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>