junit reporter does not count exceptions as failures if ok-to-fail

This commit is contained in:
Phil Nash 2017-04-11 15:47:42 +01:00
parent 2bf30e9e5a
commit e5c5a636a9
1 changed files with 7 additions and 2 deletions

View File

@ -51,7 +51,8 @@ namespace Catch {
public:
JunitReporter( ReporterConfig const& _config )
: CumulativeReporterBase( _config ),
xml( _config.stream() )
xml( _config.stream() ),
m_okToFail( false )
{
m_reporterPrefs.shouldRedirectStdOut = true;
}
@ -77,8 +78,11 @@ namespace Catch {
CumulativeReporterBase::testGroupStarting( groupInfo );
}
virtual void testCaseStarting( TestCaseInfo const& testCaseInfo ) CATCH_OVERRIDE {
m_okToFail = testCaseInfo.okToFail();
}
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail )
unexpectedExceptions++;
return CumulativeReporterBase::assertionEnded( assertionStats );
}
@ -243,6 +247,7 @@ namespace Catch {
std::ostringstream stdOutForSuite;
std::ostringstream stdErrForSuite;
unsigned int unexpectedExceptions;
bool m_okToFail;
};
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )