mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Add a new reporter customization point: reporting all assertions
By opting the JUnit and XML reporters into it, we no longer run into problem where they underreport the results without `-s` flag. Related to #1264, #1267, #1310
This commit is contained in:
		| @@ -42,6 +42,7 @@ namespace Catch { | |||||||
|  |  | ||||||
|     struct ReporterPreferences { |     struct ReporterPreferences { | ||||||
|         bool shouldRedirectStdOut = false; |         bool shouldRedirectStdOut = false; | ||||||
|  |         bool shouldReportAllAssertions = false; | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     template<typename T> |     template<typename T> | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ namespace Catch { | |||||||
|         m_config(_config), |         m_config(_config), | ||||||
|         m_reporter(std::move(reporter)), |         m_reporter(std::move(reporter)), | ||||||
|         m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, |         m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, | ||||||
|         m_includeSuccessfulResults( m_config->includeSuccessfulResults() ) |         m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) | ||||||
|     { |     { | ||||||
|         m_context.setRunner(this); |         m_context.setRunner(this); | ||||||
|         m_context.setConfig(m_config); |         m_context.setConfig(m_config); | ||||||
|   | |||||||
| @@ -245,9 +245,7 @@ private: | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         ReporterPreferences CompactReporter::getPreferences() const { |         ReporterPreferences CompactReporter::getPreferences() const { | ||||||
|             ReporterPreferences prefs; |             return m_reporterPrefs; | ||||||
|             prefs.shouldRedirectStdOut = false; |  | ||||||
|             return prefs; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         void CompactReporter::noMatchingTestCases( std::string const& spec ) { |         void CompactReporter::noMatchingTestCases( std::string const& spec ) { | ||||||
|   | |||||||
| @@ -62,6 +62,7 @@ namespace Catch { | |||||||
|             xml( _config.stream() ) |             xml( _config.stream() ) | ||||||
|         { |         { | ||||||
|             m_reporterPrefs.shouldRedirectStdOut = true; |             m_reporterPrefs.shouldRedirectStdOut = true; | ||||||
|  |             m_reporterPrefs.shouldReportAllAssertions = true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     JunitReporter::~JunitReporter() {} |     JunitReporter::~JunitReporter() {} | ||||||
|   | |||||||
| @@ -30,9 +30,7 @@ namespace Catch { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         ReporterPreferences getPreferences() const override { |         ReporterPreferences getPreferences() const override { | ||||||
|             ReporterPreferences prefs; |             return m_reporterPrefs; | ||||||
|             prefs.shouldRedirectStdOut = false; |  | ||||||
|             return prefs; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         void noMatchingTestCases( std::string const& spec ) override { |         void noMatchingTestCases( std::string const& spec ) override { | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ namespace Catch { | |||||||
|         m_xml(_config.stream()) |         m_xml(_config.stream()) | ||||||
|     { |     { | ||||||
|         m_reporterPrefs.shouldRedirectStdOut = true; |         m_reporterPrefs.shouldRedirectStdOut = true; | ||||||
|  |         m_reporterPrefs.shouldReportAllAssertions = true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     XmlReporter::~XmlReporter() = default; |     XmlReporter::~XmlReporter() = default; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský