mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
build 12
- includes updated xml reporter
This commit is contained in:
parent
c6635a7b79
commit
d76e08113b
@ -1,6 +1,6 @@
|
|||||||
![catch logo](catch-logo-small.png)
|
![catch logo](catch-logo-small.png)
|
||||||
|
|
||||||
*v1.1 build 11 (develop branch)*
|
*v1.1 build 12 (develop branch)*
|
||||||
|
|
||||||
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
Version libraryVersion( 1, 1, 11, "develop" );
|
Version libraryVersion( 1, 1, 12, "develop" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* CATCH v1.1 build 11 (develop branch)
|
* CATCH v1.1 build 12 (develop branch)
|
||||||
* Generated: 2014-12-22 20:17:55.347268
|
* Generated: 2014-12-30 18:25:37.281243
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@ -1689,6 +1689,9 @@ namespace Catch {
|
|||||||
bool allPassed() const {
|
bool allPassed() const {
|
||||||
return failed == 0 && failedButOk == 0;
|
return failed == 0 && failedButOk == 0;
|
||||||
}
|
}
|
||||||
|
bool allOk() const {
|
||||||
|
return failed == 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::size_t passed;
|
std::size_t passed;
|
||||||
std::size_t failed;
|
std::size_t failed;
|
||||||
@ -6686,7 +6689,7 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
Version libraryVersion( 1, 1, 11, "develop" );
|
Version libraryVersion( 1, 1, 12, "develop" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// #included from: catch_message.hpp
|
// #included from: catch_message.hpp
|
||||||
@ -7986,81 +7989,90 @@ namespace Catch {
|
|||||||
|
|
||||||
}
|
}
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
class XmlReporter : public SharedImpl<IReporter> {
|
class XmlReporter : public StreamingReporterBase {
|
||||||
public:
|
public:
|
||||||
XmlReporter( ReporterConfig const& config ) : m_config( config ), m_sectionDepth( 0 ) {}
|
XmlReporter( ReporterConfig const& _config )
|
||||||
|
: StreamingReporterBase( _config ),
|
||||||
|
m_sectionDepth( 0 )
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~XmlReporter();
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as an XML document";
|
return "Reports test results as an XML document";
|
||||||
}
|
}
|
||||||
virtual ~XmlReporter();
|
|
||||||
|
|
||||||
private: // IReporter
|
public: // StreamingReporterBase
|
||||||
|
virtual ReporterPreferences getPreferences() const {
|
||||||
virtual bool shouldRedirectStdout() const {
|
ReporterPreferences prefs;
|
||||||
return true;
|
prefs.shouldRedirectStdOut = true;
|
||||||
|
return prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void StartTesting() {
|
virtual void noMatchingTestCases( std::string const& s ) {
|
||||||
m_xml.setStream( m_config.stream() );
|
StreamingReporterBase::noMatchingTestCases( s );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void testRunStarting( TestRunInfo const& testInfo ) {
|
||||||
|
StreamingReporterBase::testRunStarting( testInfo );
|
||||||
|
m_xml.setStream( stream );
|
||||||
m_xml.startElement( "Catch" );
|
m_xml.startElement( "Catch" );
|
||||||
if( !m_config.fullConfig()->name().empty() )
|
if( !m_config->name().empty() )
|
||||||
m_xml.writeAttribute( "name", m_config.fullConfig()->name() );
|
m_xml.writeAttribute( "name", m_config->name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void EndTesting( const Totals& totals ) {
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) {
|
||||||
m_xml.scopedElement( "OverallResults" )
|
StreamingReporterBase::testGroupStarting( groupInfo );
|
||||||
.writeAttribute( "successes", totals.assertions.passed )
|
|
||||||
.writeAttribute( "failures", totals.assertions.failed )
|
|
||||||
.writeAttribute( "expectedFailures", totals.assertions.failedButOk );
|
|
||||||
m_xml.endElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void StartGroup( const std::string& groupName ) {
|
|
||||||
m_xml.startElement( "Group" )
|
m_xml.startElement( "Group" )
|
||||||
.writeAttribute( "name", groupName );
|
.writeAttribute( "name", groupInfo.name );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void EndGroup( const std::string&, const Totals& totals ) {
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) {
|
||||||
m_xml.scopedElement( "OverallResults" )
|
StreamingReporterBase::testCaseStarting(testInfo);
|
||||||
.writeAttribute( "successes", totals.assertions.passed )
|
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
|
||||||
.writeAttribute( "failures", totals.assertions.failed )
|
|
||||||
.writeAttribute( "expectedFailures", totals.assertions.failedButOk );
|
if ( m_config->showDurations() == ShowDurations::Always )
|
||||||
m_xml.endElement();
|
m_testCaseTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void StartSection( const std::string& sectionName, const std::string& description ) {
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) {
|
||||||
|
StreamingReporterBase::sectionStarting( sectionInfo );
|
||||||
if( m_sectionDepth++ > 0 ) {
|
if( m_sectionDepth++ > 0 ) {
|
||||||
m_xml.startElement( "Section" )
|
m_xml.startElement( "Section" )
|
||||||
.writeAttribute( "name", trim( sectionName ) )
|
.writeAttribute( "name", trim( sectionInfo.name ) )
|
||||||
.writeAttribute( "description", description );
|
.writeAttribute( "description", sectionInfo.description );
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void NoAssertionsInSection( const std::string& ) {}
|
|
||||||
virtual void NoAssertionsInTestCase( const std::string& ) {}
|
|
||||||
|
|
||||||
virtual void EndSection( const std::string& /*sectionName*/, const Counts& assertions ) {
|
|
||||||
if( --m_sectionDepth > 0 ) {
|
|
||||||
m_xml.scopedElement( "OverallResults" )
|
|
||||||
.writeAttribute( "successes", assertions.passed )
|
|
||||||
.writeAttribute( "failures", assertions.failed )
|
|
||||||
.writeAttribute( "expectedFailures", assertions.failedButOk );
|
|
||||||
m_xml.endElement();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
|
virtual void assertionStarting( AssertionInfo const& ) { }
|
||||||
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
|
|
||||||
m_currentTestSuccess = true;
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
||||||
|
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
||||||
|
|
||||||
|
// Print any info messages in <Info> tags.
|
||||||
|
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
|
||||||
|
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it ) {
|
||||||
|
if( it->type == ResultWas::Info ) {
|
||||||
|
m_xml.scopedElement( "Info" )
|
||||||
|
.writeText( it->message );
|
||||||
|
} else if ( it->type == ResultWas::Warning ) {
|
||||||
|
m_xml.scopedElement( "Warning" )
|
||||||
|
.writeText( it->message );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Result( const Catch::AssertionResult& assertionResult ) {
|
// Drop out if result was successful but we're not printing them.
|
||||||
if( !m_config.fullConfig()->includeSuccessfulResults() && assertionResult.getResultType() == ResultWas::Ok )
|
if( !m_config->includeSuccessfulResults() && isOk(assertionResult.getResultType()) )
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
|
// Print the expression if there is one.
|
||||||
if( assertionResult.hasExpression() ) {
|
if( assertionResult.hasExpression() ) {
|
||||||
m_xml.startElement( "Expression" )
|
m_xml.startElement( "Expression" )
|
||||||
.writeAttribute( "success", assertionResult.succeeded() )
|
.writeAttribute( "success", assertionResult.succeeded() )
|
||||||
|
.writeAttribute( "type", assertionResult.getTestMacroName() )
|
||||||
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
||||||
.writeAttribute( "line", assertionResult.getSourceInfo().line );
|
.writeAttribute( "line", assertionResult.getSourceInfo().line );
|
||||||
|
|
||||||
@ -8068,65 +8080,96 @@ namespace Catch {
|
|||||||
.writeText( assertionResult.getExpression() );
|
.writeText( assertionResult.getExpression() );
|
||||||
m_xml.scopedElement( "Expanded" )
|
m_xml.scopedElement( "Expanded" )
|
||||||
.writeText( assertionResult.getExpandedExpression() );
|
.writeText( assertionResult.getExpandedExpression() );
|
||||||
m_currentTestSuccess &= assertionResult.succeeded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// And... Print a result applicable to each result type.
|
||||||
switch( assertionResult.getResultType() ) {
|
switch( assertionResult.getResultType() ) {
|
||||||
case ResultWas::ThrewException:
|
case ResultWas::ThrewException:
|
||||||
m_xml.scopedElement( "Exception" )
|
m_xml.scopedElement( "Exception" )
|
||||||
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
||||||
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
||||||
.writeText( assertionResult.getMessage() );
|
.writeText( assertionResult.getMessage() );
|
||||||
m_currentTestSuccess = false;
|
|
||||||
break;
|
break;
|
||||||
case ResultWas::FatalErrorCondition:
|
case ResultWas::FatalErrorCondition:
|
||||||
m_xml.scopedElement( "Fatal Error Condition" )
|
m_xml.scopedElement( "Fatal Error Condition" )
|
||||||
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
||||||
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
||||||
.writeText( assertionResult.getMessage() );
|
.writeText( assertionResult.getMessage() );
|
||||||
m_currentTestSuccess = false;
|
|
||||||
break;
|
break;
|
||||||
case ResultWas::Info:
|
case ResultWas::Info:
|
||||||
m_xml.scopedElement( "Info" )
|
m_xml.scopedElement( "Info" )
|
||||||
.writeText( assertionResult.getMessage() );
|
.writeText( assertionResult.getMessage() );
|
||||||
break;
|
break;
|
||||||
case ResultWas::Warning:
|
case ResultWas::Warning:
|
||||||
m_xml.scopedElement( "Warning" )
|
// Warning will already have been written
|
||||||
.writeText( assertionResult.getMessage() );
|
|
||||||
break;
|
break;
|
||||||
case ResultWas::ExplicitFailure:
|
case ResultWas::ExplicitFailure:
|
||||||
m_xml.scopedElement( "Failure" )
|
m_xml.scopedElement( "Failure" )
|
||||||
.writeText( assertionResult.getMessage() );
|
.writeText( assertionResult.getMessage() );
|
||||||
m_currentTestSuccess = false;
|
|
||||||
break;
|
break;
|
||||||
case ResultWas::Unknown:
|
default:
|
||||||
case ResultWas::Ok:
|
|
||||||
case ResultWas::FailureBit:
|
|
||||||
case ResultWas::ExpressionFailed:
|
|
||||||
case ResultWas::Exception:
|
|
||||||
case ResultWas::DidntThrowException:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( assertionResult.hasExpression() )
|
if( assertionResult.hasExpression() )
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void sectionEnded( SectionStats const& sectionStats ) {
|
||||||
|
StreamingReporterBase::sectionEnded( sectionStats );
|
||||||
|
if( --m_sectionDepth > 0 ) {
|
||||||
|
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
|
||||||
|
e.writeAttribute( "successes", sectionStats.assertions.passed );
|
||||||
|
e.writeAttribute( "failures", sectionStats.assertions.failed );
|
||||||
|
e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk );
|
||||||
|
|
||||||
|
if ( m_config->showDurations() == ShowDurations::Always )
|
||||||
|
e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds );
|
||||||
|
|
||||||
|
m_xml.endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
||||||
|
StreamingReporterBase::testCaseEnded( testCaseStats );
|
||||||
|
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
|
||||||
|
e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() );
|
||||||
|
|
||||||
|
if ( m_config->showDurations() == ShowDurations::Always )
|
||||||
|
e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() );
|
||||||
|
|
||||||
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Aborted() {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
||||||
// !TBD
|
StreamingReporterBase::testGroupEnded( testGroupStats );
|
||||||
|
// TODO: Check testGroupStats.aborting and act accordingly.
|
||||||
|
m_xml.scopedElement( "OverallResults" )
|
||||||
|
.writeAttribute( "successes", testGroupStats.totals.assertions.passed )
|
||||||
|
.writeAttribute( "failures", testGroupStats.totals.assertions.failed )
|
||||||
|
.writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk );
|
||||||
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string&, const std::string& ) {
|
virtual void testRunEnded( TestRunStats const& testRunStats ) {
|
||||||
m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess );
|
StreamingReporterBase::testRunEnded( testRunStats );
|
||||||
|
m_xml.scopedElement( "OverallResults" )
|
||||||
|
.writeAttribute( "successes", testRunStats.totals.assertions.passed )
|
||||||
|
.writeAttribute( "failures", testRunStats.totals.assertions.failed )
|
||||||
|
.writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk );
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ReporterConfig m_config;
|
Timer m_testCaseTimer;
|
||||||
bool m_currentTestSuccess;
|
|
||||||
XmlWriter m_xml;
|
XmlWriter m_xml;
|
||||||
int m_sectionDepth;
|
int m_sectionDepth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter )
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
// #included from: ../reporters/catch_reporter_junit.hpp
|
// #included from: ../reporters/catch_reporter_junit.hpp
|
||||||
@ -9119,8 +9162,6 @@ namespace Catch {
|
|||||||
Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
||||||
|
|
||||||
void Config::dummy() {}
|
void Config::dummy() {}
|
||||||
|
|
||||||
INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( "xml", XmlReporter )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
Loading…
Reference in New Issue
Block a user