diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp index d8311968..7c993c09 100644 --- a/include/catch_runner.hpp +++ b/include/catch_runner.hpp @@ -56,8 +56,8 @@ namespace Catch { Totals runTestsForGroup( Runner& context, const TestCaseFilters& filterGroup ) { Totals totals; - std::vector::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin(); - std::vector::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end(); + std::vector::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin(); + std::vector::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end(); int testsRunForGroup = 0; for(; it != itEnd; ++it ) { if( filterGroup.shouldInclude( *it ) ) { @@ -114,7 +114,7 @@ namespace Catch { const ConfigData& m_config; std::ofstream m_ofs; Ptr m_reporter; - std::set m_testsAlreadyRun; + std::set m_testsAlreadyRun; }; inline int Main( Config& configWrapper ) { diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h index 51716733..831d22a3 100644 --- a/include/internal/catch_context.h +++ b/include/internal/catch_context.h @@ -16,7 +16,7 @@ namespace Catch { - class TestCaseInfo; + class TestCase; class Stream; struct IResultCapture; struct IRunner; diff --git a/include/internal/catch_interfaces_capture.h b/include/internal/catch_interfaces_capture.h index 3cbbb88e..3f01bd0b 100644 --- a/include/internal/catch_interfaces_capture.h +++ b/include/internal/catch_interfaces_capture.h @@ -15,7 +15,7 @@ namespace Catch { - class TestCaseInfo; + class TestCase; class ScopedInfo; class ExpressionResultBuilder; class AssertionResult; diff --git a/include/internal/catch_interfaces_registry_hub.h b/include/internal/catch_interfaces_registry_hub.h index da2d7fd4..7d932bde 100644 --- a/include/internal/catch_interfaces_registry_hub.h +++ b/include/internal/catch_interfaces_registry_hub.h @@ -15,7 +15,7 @@ namespace Catch { - class TestCaseInfo; + class TestCase; struct ITestCaseRegistry; struct IExceptionTranslatorRegistry; struct IExceptionTranslator; @@ -31,7 +31,7 @@ namespace Catch { struct IMutableRegistryHub { virtual ~IMutableRegistryHub(); virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0; - virtual void registerTest( const TestCaseInfo& testInfo ) = 0; + virtual void registerTest( const TestCase& testInfo ) = 0; virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; }; diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 847016ad..96075933 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -12,6 +12,8 @@ #include "catch_totals.hpp" #include "catch_ptr.hpp" #include "catch_config.hpp" +#include "catch_test_case_info.h" +#include "catch_assertionresult.h" #include #include @@ -47,10 +49,54 @@ namespace Catch private: void operator=(const ReporterConfig&); }; + + struct AssertionStats { + AssertionInfo assertionInfo; + AssertionResult assertionResult; + Totals totals; + }; + + struct TestCaseStats { + TestCase testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; + }; - class TestCaseInfo; - class AssertionResult; + struct TestGroupStats { + std::string groupName; + Totals totals; + bool aborting; + }; + struct TestRunStats { + std::string runName; + Totals totals; + bool aborting; + }; + + // !Work In progress + struct IStreamingReporter : IShared { + virtual void testRunStarting( const std::string& runName ) = 0; + virtual void testGroupStarting( const std::string& groupName ) = 0; + + // !TBD: include section info (perhaps TestCase has an isSection flag and/ or a parent pointer + virtual void testCaseStarting( const TestCase& testInfo ) = 0; + virtual void assertionStarting( const AssertionInfo& assertionInfo ) = 0; + + virtual void assertionEnding( const AssertionStats& assertionStats ) = 0; + virtual void testCaseEnding( const TestCaseStats& testCaseStats ) = 0; + virtual void testGroupEnding( const TestGroupStats& testGroupStats ) = 0; + virtual void testRunEnding( const TestRunStats& testRunStats ) = 0; + }; + // !TBD: Derived helper that implements the streaming interface but holds the stats + // - declares a new interface where methods are called at the end of each event + // - this would be used by the JUnit reporter, for example. + // - it may be used by the basic reporter, too, but that would clear down the stack + // as it goes + + struct IReporter : IShared { virtual ~IReporter(); @@ -62,9 +108,9 @@ namespace Catch virtual void StartGroup( const std::string& groupName ) = 0; virtual void EndGroup( const std::string& groupName, const Totals& totals ) = 0; - virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0; + virtual void StartTestCase( const TestCase& testInfo ) = 0; // TestCaseResult - virtual void EndTestCase( const TestCaseInfo& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0; + virtual void EndTestCase( const TestCase& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0; // SectionInfo virtual void StartSection( const std::string& sectionName, const std::string& description ) = 0; diff --git a/include/internal/catch_interfaces_runner.h b/include/internal/catch_interfaces_runner.h index e59d64f2..bb81ffb4 100644 --- a/include/internal/catch_interfaces_runner.h +++ b/include/internal/catch_interfaces_runner.h @@ -13,7 +13,7 @@ #include namespace Catch { - class TestCaseInfo; + class TestCase; struct IRunner { virtual ~IRunner(); diff --git a/include/internal/catch_interfaces_testcase.h b/include/internal/catch_interfaces_testcase.h index 94ddf6f7..3f0c7078 100644 --- a/include/internal/catch_interfaces_testcase.h +++ b/include/internal/catch_interfaces_testcase.h @@ -22,12 +22,12 @@ namespace Catch { virtual ~ITestCase(); }; - class TestCaseInfo; + class TestCase; struct ITestCaseRegistry { virtual ~ITestCaseRegistry(); - virtual const std::vector& getAllTests() const = 0; - virtual std::vector getMatchingTestCases( const std::string& rawTestSpec ) const = 0; + virtual const std::vector& getAllTests() const = 0; + virtual std::vector getMatchingTestCases( const std::string& rawTestSpec ) const = 0; }; } diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp index 82586a1b..2b41cda8 100644 --- a/include/internal/catch_list.hpp +++ b/include/internal/catch_list.hpp @@ -12,7 +12,7 @@ #include namespace Catch { - inline bool matchesFilters( const std::vector& filters, const TestCaseInfo& testCase ) { + inline bool matchesFilters( const std::vector& filters, const TestCase& testCase ) { std::vector::const_iterator it = filters.begin(); std::vector::const_iterator itEnd = filters.end(); for(; it != itEnd; ++it ) @@ -38,8 +38,8 @@ namespace Catch { std::cout << "All available test cases:\n"; else std::cout << "Matching test cases:\n"; - std::vector::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin(); - std::vector::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end(); + std::vector::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin(); + std::vector::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end(); std::size_t matchedTests = 0; for(; it != itEnd; ++it ) { if( matchesFilters( config.filters, *it ) ) { diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index fabfda8f..dbc5a97f 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -93,7 +93,7 @@ namespace Catch { std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); - getMutableRegistryHub().registerTest( TestCaseInfo( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) ); + getMutableRegistryHub().registerTest( TestCase( new OcMethod( cls, selector ), name.c_str(), desc.c_str(), SourceLineInfo() ) ); noTestMethods++; } } diff --git a/include/internal/catch_registry_hub.hpp b/include/internal/catch_registry_hub.hpp index d66205de..05d602e1 100644 --- a/include/internal/catch_registry_hub.hpp +++ b/include/internal/catch_registry_hub.hpp @@ -40,7 +40,7 @@ namespace Catch { virtual void registerReporter( const std::string& name, IReporterFactory* factory ) { m_reporterRegistry.registerReporter( name, factory ); } - virtual void registerTest( const TestCaseInfo& testInfo ) { + virtual void registerTest( const TestCase& testInfo ) { m_testCaseRegistry.registerTest( testInfo ); } virtual void registerTranslator( const IExceptionTranslator* translator ) { diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 5d4c2145..596fc1b8 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -81,14 +81,14 @@ namespace Catch { Totals runMatching( const std::string& testSpec ) { - std::vector matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec ); + std::vector matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec ); Totals totals; m_reporter->StartGroup( testSpec ); - std::vector::const_iterator it = matchingTests.begin(); - std::vector::const_iterator itEnd = matchingTests.end(); + std::vector::const_iterator it = matchingTests.begin(); + std::vector::const_iterator itEnd = matchingTests.end(); for(; it != itEnd; ++it ) totals += runTest( *it ); // !TBD use std::accumulate? @@ -97,7 +97,7 @@ namespace Catch { return totals; } - Totals runTest( const TestCaseInfo& testInfo ) { + Totals runTest( const TestCase& testInfo ) { Totals prevTotals = m_totals; std::string redirectedCout; @@ -120,7 +120,7 @@ namespace Catch { ( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) ) { m_totals.assertions.failed++; deltaTotals = m_totals.delta( prevTotals ); - m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCaseInfo().getName() ); + m_reporter->NoAssertionsInTestCase( m_runningTest->getTestCase().getName() ); } m_totals.testCases += deltaTotals.testCases; @@ -228,7 +228,7 @@ namespace Catch { virtual std::string getCurrentTestName() const { return m_runningTest - ? m_runningTest->getTestCaseInfo().getName() + ? m_runningTest->getTestCase().getName() : ""; } @@ -262,15 +262,15 @@ namespace Catch { void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) { try { - m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCaseInfo().getLineInfo(), "", ResultDisposition::Normal ); + m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCase().getLineInfo(), "", ResultDisposition::Normal ); m_runningTest->reset(); if( m_reporter->shouldRedirectStdout() ) { StreamRedirect coutRedir( std::cout, redirectedCout ); StreamRedirect cerrRedir( std::cerr, redirectedCerr ); - m_runningTest->getTestCaseInfo().invoke(); + m_runningTest->getTestCase().invoke(); } else { - m_runningTest->getTestCaseInfo().invoke(); + m_runningTest->getTestCase().invoke(); } m_runningTest->ranToCompletion(); } diff --git a/include/internal/catch_running_test.hpp b/include/internal/catch_running_test.hpp index 3fce399e..2bda148c 100644 --- a/include/internal/catch_running_test.hpp +++ b/include/internal/catch_running_test.hpp @@ -24,7 +24,7 @@ namespace Catch { }; public: - explicit RunningTest( const TestCaseInfo* info = NULL ) + explicit RunningTest( const TestCase* info = NULL ) : m_info( info ), m_runStatus( RanAtLeastOneSection ), m_currentSection( &m_rootSection ), @@ -97,7 +97,7 @@ namespace Catch { m_currentSection = m_currentSection->getParent(); } - const TestCaseInfo& getTestCaseInfo() const { + const TestCase& getTestCase() const { return *m_info; } @@ -107,7 +107,7 @@ namespace Catch { } private: - const TestCaseInfo* m_info; + const TestCase* m_info; RunStatus m_runStatus; SectionInfo m_rootSection; SectionInfo* m_currentSection; diff --git a/include/internal/catch_test_case_info.h b/include/internal/catch_test_case_info.h index 1fce27fb..5a7d7438 100644 --- a/include/internal/catch_test_case_info.h +++ b/include/internal/catch_test_case_info.h @@ -16,20 +16,20 @@ namespace Catch { struct ITestCase; - - class TestCaseInfo { + + class TestCase { public: - TestCaseInfo(); + TestCase(); - TestCaseInfo( ITestCase* testCase, + TestCase( ITestCase* testCase, const std::string& className, const std::string& name, const std::string& description, const SourceLineInfo& lineInfo ); - TestCaseInfo( const TestCaseInfo& other, const std::string& name ); - TestCaseInfo( const TestCaseInfo& other ); + TestCase( const TestCase& other, const std::string& name ); + TestCase( const TestCase& other ); void invoke() const; @@ -42,10 +42,10 @@ namespace Catch { bool matchesTags( const std::string& tagPattern ) const; const std::set& getTags() const; - void swap( TestCaseInfo& other ); - bool operator == ( const TestCaseInfo& other ) const; - bool operator < ( const TestCaseInfo& other ) const; - TestCaseInfo& operator = ( const TestCaseInfo& other ); + void swap( TestCase& other ); + bool operator == ( const TestCase& other ) const; + bool operator < ( const TestCase& other ) const; + TestCase& operator = ( const TestCase& other ); private: Ptr m_test; diff --git a/include/internal/catch_test_case_info.hpp b/include/internal/catch_test_case_info.hpp index bb50759a..3d782e11 100644 --- a/include/internal/catch_test_case_info.hpp +++ b/include/internal/catch_test_case_info.hpp @@ -15,7 +15,7 @@ namespace Catch { - TestCaseInfo::TestCaseInfo( ITestCase* testCase, + TestCase::TestCase( ITestCase* testCase, const std::string& className, const std::string& name, const std::string& description, @@ -32,7 +32,7 @@ namespace Catch { m_isHidden = true; } - TestCaseInfo::TestCaseInfo() + TestCase::TestCase() : m_test( NULL ), m_className(), m_name(), @@ -40,7 +40,7 @@ namespace Catch { m_isHidden( false ) {} - TestCaseInfo::TestCaseInfo( const TestCaseInfo& other, const std::string& name ) + TestCase::TestCase( const TestCase& other, const std::string& name ) : m_test( other.m_test ), m_className( other.m_className ), m_name( name ), @@ -50,7 +50,7 @@ namespace Catch { m_isHidden( other.m_isHidden ) {} - TestCaseInfo::TestCaseInfo( const TestCaseInfo& other ) + TestCase::TestCase( const TestCase& other ) : m_test( other.m_test ), m_className( other.m_className ), m_name( other.m_name ), @@ -60,40 +60,40 @@ namespace Catch { m_isHidden( other.m_isHidden ) {} - void TestCaseInfo::invoke() const { + void TestCase::invoke() const { m_test->invoke(); } - const std::string& TestCaseInfo::getClassName() const { + const std::string& TestCase::getClassName() const { return m_className; } - const std::string& TestCaseInfo::getName() const { + const std::string& TestCase::getName() const { return m_name; } - const std::string& TestCaseInfo::getDescription() const { + const std::string& TestCase::getDescription() const { return m_description; } - const SourceLineInfo& TestCaseInfo::getLineInfo() const { + const SourceLineInfo& TestCase::getLineInfo() const { return m_lineInfo; } - bool TestCaseInfo::isHidden() const { + bool TestCase::isHidden() const { return m_isHidden; } - bool TestCaseInfo::hasTag( const std::string& tag ) const { + bool TestCase::hasTag( const std::string& tag ) const { return m_tags.find( tag ) != m_tags.end(); } - bool TestCaseInfo::matchesTags( const std::string& tagPattern ) const { + bool TestCase::matchesTags( const std::string& tagPattern ) const { TagExpression exp; TagExpressionParser( exp ).parse( tagPattern ); return exp.matches( m_tags ); } - const std::set& TestCaseInfo::getTags() const { + const std::set& TestCase::getTags() const { return m_tags; } - void TestCaseInfo::swap( TestCaseInfo& other ) { + void TestCase::swap( TestCase& other ) { m_test.swap( other.m_test ); m_className.swap( other.m_className ); m_name.swap( other.m_name ); @@ -101,17 +101,17 @@ namespace Catch { std::swap( m_lineInfo, other.m_lineInfo ); } - bool TestCaseInfo::operator == ( const TestCaseInfo& other ) const { + bool TestCase::operator == ( const TestCase& other ) const { return m_test.get() == other.m_test.get() && m_name == other.m_name && m_className == other.m_className; } - bool TestCaseInfo::operator < ( const TestCaseInfo& other ) const { + bool TestCase::operator < ( const TestCase& other ) const { return m_name < other.m_name; } - TestCaseInfo& TestCaseInfo::operator = ( const TestCaseInfo& other ) { - TestCaseInfo temp( other ); + TestCase& TestCase::operator = ( const TestCase& other ) { + TestCase temp( other ); swap( temp ); return *this; } diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index adaefc35..715a96e9 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -25,11 +25,11 @@ namespace Catch { TestRegistry() : m_unnamedCount( 0 ) {} virtual ~TestRegistry(); - virtual void registerTest( const TestCaseInfo& testInfo ) { + virtual void registerTest( const TestCase& testInfo ) { if( testInfo.getName() == "" ) { std::ostringstream oss; oss << testInfo.getName() << "unnamed/" << ++m_unnamedCount; - return registerTest( TestCaseInfo( testInfo, oss.str() ) ); + return registerTest( TestCase( testInfo, oss.str() ) ); } if( m_functions.find( testInfo ) == m_functions.end() ) { @@ -39,7 +39,7 @@ namespace Catch { m_nonHiddenFunctions.push_back( testInfo ); } else { - const TestCaseInfo& prev = *m_functions.find( testInfo ); + const TestCase& prev = *m_functions.find( testInfo ); std::cerr << "error: TEST_CASE( \"" << testInfo.getName() << "\" ) already defined.\n" << "\tFirst seen at " << SourceLineInfo( prev.getLineInfo() ) << "\n" << "\tRedefined at " << SourceLineInfo( testInfo.getLineInfo() ) << std::endl; @@ -47,36 +47,36 @@ namespace Catch { } } - virtual const std::vector& getAllTests() const { + virtual const std::vector& getAllTests() const { return m_functionsInOrder; } - virtual const std::vector& getAllNonHiddenTests() const { + virtual const std::vector& getAllNonHiddenTests() const { return m_nonHiddenFunctions; } // !TBD deprecated - virtual std::vector getMatchingTestCases( const std::string& rawTestSpec ) const { - std::vector matchingTests; + virtual std::vector getMatchingTestCases( const std::string& rawTestSpec ) const { + std::vector matchingTests; getMatchingTestCases( rawTestSpec, matchingTests ); return matchingTests; } // !TBD deprecated - virtual void getMatchingTestCases( const std::string& rawTestSpec, std::vector& matchingTestsOut ) const { + virtual void getMatchingTestCases( const std::string& rawTestSpec, std::vector& matchingTestsOut ) const { TestCaseFilter filter( rawTestSpec ); - std::vector::const_iterator it = m_functionsInOrder.begin(); - std::vector::const_iterator itEnd = m_functionsInOrder.end(); + std::vector::const_iterator it = m_functionsInOrder.begin(); + std::vector::const_iterator itEnd = m_functionsInOrder.end(); for(; it != itEnd; ++it ) { if( filter.shouldInclude( *it ) ) { matchingTestsOut.push_back( *it ); } } } - virtual void getMatchingTestCases( const TestCaseFilters& filters, std::vector& matchingTestsOut ) const { - std::vector::const_iterator it = m_functionsInOrder.begin(); - std::vector::const_iterator itEnd = m_functionsInOrder.end(); + virtual void getMatchingTestCases( const TestCaseFilters& filters, std::vector& matchingTestsOut ) const { + std::vector::const_iterator it = m_functionsInOrder.begin(); + std::vector::const_iterator itEnd = m_functionsInOrder.end(); // !TBD: replace with algorithm for(; it != itEnd; ++it ) if( filters.shouldInclude( *it ) ) @@ -85,9 +85,9 @@ namespace Catch { private: - std::set m_functions; - std::vector m_functionsInOrder; - std::vector m_nonHiddenFunctions; + std::set m_functions; + std::vector m_functionsInOrder; + std::vector m_nonHiddenFunctions; size_t m_unnamedCount; }; @@ -138,7 +138,7 @@ namespace Catch { const char* description, const SourceLineInfo& lineInfo ) { - getMutableRegistryHub().registerTest( TestCaseInfo( testCase, extractClassName( classOrQualifiedMethodName ), name, description, lineInfo ) ); + getMutableRegistryHub().registerTest( TestCase( testCase, extractClassName( classOrQualifiedMethodName ), name, description, lineInfo ) ); } } // end namespace Catch diff --git a/include/internal/catch_test_spec.h b/include/internal/catch_test_spec.h index 2c028d4e..3e726d8c 100644 --- a/include/internal/catch_test_spec.h +++ b/include/internal/catch_test_spec.h @@ -64,7 +64,7 @@ namespace Catch { return m_filterType; } - bool shouldInclude( const TestCaseInfo& testCase ) const { + bool shouldInclude( const TestCase& testCase ) const { return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests); } private: @@ -74,7 +74,7 @@ namespace Catch { #pragma clang diagnostic ignored "-Wunreachable-code" #endif - bool isMatch( const TestCaseInfo& testCase ) const { + bool isMatch( const TestCase& testCase ) const { const std::string& name = testCase.getName(); switch( m_wildcardPosition ) { @@ -121,7 +121,7 @@ namespace Catch { m_tagExpressions.push_back( exp ); } - bool shouldInclude( const TestCaseInfo& testCase ) const { + bool shouldInclude( const TestCase& testCase ) const { if( !m_tagExpressions.empty() ) { std::vector::const_iterator it = m_tagExpressions.begin(); std::vector::const_iterator itEnd = m_tagExpressions.end(); diff --git a/include/reporters/catch_reporter_basic.hpp b/include/reporters/catch_reporter_basic.hpp index 647fede5..508d18e5 100644 --- a/include/reporters/catch_reporter_basic.hpp +++ b/include/reporters/catch_reporter_basic.hpp @@ -120,7 +120,7 @@ namespace Catch { } } - virtual void StartTestCase( const TestCaseInfo& testInfo ) { + virtual void StartTestCase( const TestCase& testInfo ) { m_testSpan = testInfo.getName(); } @@ -264,7 +264,7 @@ namespace Catch { m_config.stream << std::endl; } - virtual void EndTestCase( const TestCaseInfo& testInfo, + virtual void EndTestCase( const TestCase& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) { diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp index 8fac30d1..e39e6896 100644 --- a/include/reporters/catch_reporter_junit.hpp +++ b/include/reporters/catch_reporter_junit.hpp @@ -38,6 +38,7 @@ namespace Catch { std::string m_stdOut; std::string m_stdErr; std::vector m_testStats; + std::vector m_sections; }; struct Stats { @@ -101,8 +102,9 @@ namespace Catch { virtual void EndSection( const std::string&, const Counts& ) {} - virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) { + virtual void StartTestCase( const Catch::TestCase& testInfo ) { m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getClassName(), testInfo.getName() ) ); + m_currentTestCaseStats.push_back( &m_currentStats->m_testCaseStats.back() ); } virtual void Result( const Catch::AssertionResult& assertionResult ) { @@ -149,7 +151,9 @@ namespace Catch { } } - virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string& stdOut, const std::string& stdErr ) { + virtual void EndTestCase( const Catch::TestCase&, const Totals&, const std::string& stdOut, const std::string& stdErr ) { + m_currentTestCaseStats.pop_back(); + assert( m_currentTestCaseStats.empty() ); TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back(); testCaseStats.m_stdOut = stdOut; testCaseStats.m_stdErr = stdErr; @@ -236,6 +240,7 @@ namespace Catch { Stats m_testSuiteStats; Stats* m_currentStats; std::vector m_statsForSuites; + std::vector m_currentTestCaseStats; std::ostringstream m_stdOut; std::ostringstream m_stdErr; }; diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp index d2163dd3..a38b1031 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -70,7 +70,7 @@ namespace Catch { m_xml.endElement(); } - virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) { + virtual void StartTestCase( const Catch::TestCase& testInfo ) { m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.getName() ); m_currentTestSuccess = true; } @@ -129,7 +129,7 @@ namespace Catch { // !TBD } - virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string&, const std::string& ) { + virtual void EndTestCase( const Catch::TestCase&, const Totals&, const std::string&, const std::string& ) { m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess ); m_xml.endElement(); } diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index 90116c61..229e7405 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -86,7 +86,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co return ""; } -inline Catch::TestCaseInfo makeTestCase( const char* name ){ return Catch::TestCaseInfo( NULL, "", name, "", CATCH_INTERNAL_LINEINFO ); } +inline Catch::TestCase makeTestCase( const char* name ){ return Catch::TestCase( NULL, "", name, "", CATCH_INTERNAL_LINEINFO ); } TEST_CASE( "selftest/parser/2", "ConfigData" ) { @@ -364,7 +364,7 @@ TEST_CASE( "selftest/tags", "" ) { std::string p5 = "[one][two]~[hide],[three]"; SECTION( "one tag", "" ) { - Catch::TestCaseInfo oneTag( NULL, "", "test", "[one]", CATCH_INTERNAL_LINEINFO ); + Catch::TestCase oneTag( NULL, "", "test", "[one]", CATCH_INTERNAL_LINEINFO ); CHECK( oneTag.getDescription() == "" ); CHECK( oneTag.hasTag( "one" ) ); @@ -378,7 +378,7 @@ TEST_CASE( "selftest/tags", "" ) { } SECTION( "two tags", "" ) { - Catch::TestCaseInfo twoTags( NULL, "", "test", "[one][two]", CATCH_INTERNAL_LINEINFO ); + Catch::TestCase twoTags( NULL, "", "test", "[one][two]", CATCH_INTERNAL_LINEINFO ); CHECK( twoTags.getDescription() == "" ); CHECK( twoTags.hasTag( "one" ) ); @@ -395,7 +395,7 @@ TEST_CASE( "selftest/tags", "" ) { SECTION( "one tag with characters either side", "" ) { - Catch::TestCaseInfo oneTagWithExtras( NULL, "", "test", "12[one]34", CATCH_INTERNAL_LINEINFO ); + Catch::TestCase oneTagWithExtras( NULL, "", "test", "12[one]34", CATCH_INTERNAL_LINEINFO ); CHECK( oneTagWithExtras.getDescription() == "1234" ); CHECK( oneTagWithExtras.hasTag( "one" ) ); CHECK( oneTagWithExtras.hasTag( "two" ) == false ); @@ -404,7 +404,7 @@ TEST_CASE( "selftest/tags", "" ) { SECTION( "start of a tag, but not closed", "" ) { - Catch::TestCaseInfo oneTagOpen( NULL, "", "test", "[one", CATCH_INTERNAL_LINEINFO ); + Catch::TestCase oneTagOpen( NULL, "", "test", "[one", CATCH_INTERNAL_LINEINFO ); CHECK( oneTagOpen.getDescription() == "[one" ); CHECK( oneTagOpen.hasTag( "one" ) == false ); @@ -412,7 +412,7 @@ TEST_CASE( "selftest/tags", "" ) { } SECTION( "hidden", "" ) { - Catch::TestCaseInfo oneTag( NULL, "", "test", "[hide]", CATCH_INTERNAL_LINEINFO ); + Catch::TestCase oneTag( NULL, "", "test", "[hide]", CATCH_INTERNAL_LINEINFO ); CHECK( oneTag.getDescription() == "" ); CHECK( oneTag.hasTag( "hide" ) ); diff --git a/projects/SelfTest/catch_self_test.hpp b/projects/SelfTest/catch_self_test.hpp index 12ad282e..5c30dd63 100644 --- a/projects/SelfTest/catch_self_test.hpp +++ b/projects/SelfTest/catch_self_test.hpp @@ -82,13 +82,13 @@ namespace Catch { closeLabel( recordSections, sectionName ); } - virtual void StartTestCase( const TestCaseInfo& testInfo ) { + virtual void StartTestCase( const TestCase& testInfo ) { openLabel( recordTestCases, testInfo.getName() ); } virtual void Aborted(){} - virtual void EndTestCase( const TestCaseInfo& testInfo, + virtual void EndTestCase( const TestCase& testInfo, const Totals&, const std::string&, const std::string& ) { @@ -153,7 +153,7 @@ namespace Catch { MetaTestRunner( expectedResult ) ); } - void operator()( const TestCaseInfo& testCase ) { + void operator()( const TestCase& testCase ) { EmbeddedRunner runner; Totals totals = runner.runMatching( testCase.getName() ); switch( m_expectedResult ) {