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

Only report test case once for all sections within it

Commit
455c2998a00bdc4dcb0afb83dbaee7eb19795f7f
Author
Phil Nash ·
Parents
6a6b346731d4

Files · Download .tar.gz

Changes

 internal/catch_runner_impl.hpp | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/internal/catch_runner_impl.hpp b/internal/catch_runner_impl.hpp
index 7faab9bb..7ba1bb9c 100644
--- a/internal/catch_runner_impl.hpp
+++ b/internal/catch_runner_impl.hpp
@@ -187,16 +187,26 @@ namespace Catch
             const TestCaseInfo& testInfo
         )
         {
+            std::size_t prevSuccessCount = m_successes;
+            std::size_t prevFailureCount = m_failures;
+
+            std::string redirectedCout;
+            std::string redirectedCerr;
+            
+            m_reporter->StartTestCase( testInfo );
+            
             m_runningTest = RunningTest( &testInfo );
 
             do
             {
                 m_runningTest.resetSectionSeen();
-                runCurrentTest();
+                runCurrentTest( redirectedCout, redirectedCerr );
             }
             while( m_runningTest.wasSectionSeen() );
 
             m_runningTest = RunningTest();
+
+            m_reporter->EndTestCase( testInfo, m_successes - prevSuccessCount, m_failures - prevFailureCount, redirectedCout, redirectedCerr );
         }
         
         ///////////////////////////////////////////////////////////////////////////
@@ -352,16 +362,11 @@ namespace Catch
         
         ///////////////////////////////////////////////////////////////////////////
         void runCurrentTest
-        ()
-        {
-            std::size_t prevSuccessCount = m_successes;
-            std::size_t prevFailureCount = m_failures;
-            
-            m_reporter->StartTestCase( m_runningTest.getTestCaseInfo() );
-            
-            std::string redirectedCout;
-            std::string redirectedCerr;
-            
+        (
+            std::string& redirectedCout,
+            std::string& redirectedCerr
+        )
+        {            
             try
             {
                 StreamRedirect coutRedir( std::cout, redirectedCout );
@@ -383,7 +388,6 @@ namespace Catch
                 acceptResult( ResultWas::ThrewException );
             }
             m_info.clear();
-            m_reporter->EndTestCase( m_runningTest.getTestCaseInfo(), m_successes - prevSuccessCount, m_failures - prevFailureCount, redirectedCout, redirectedCerr );
         }
         
     private: