mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Add file/line to TestCase, Section and Failure elements in Xml Reporter
This commit is contained in:
parent
c6178601c5
commit
90b3946e9c
@ -36,6 +36,12 @@ namespace Catch {
|
|||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeSourceInfo( SourceLineInfo const& sourceInfo ) {
|
||||||
|
m_xml
|
||||||
|
.writeAttribute( "filename", sourceInfo.file )
|
||||||
|
.writeAttribute( "line", sourceInfo.line );
|
||||||
|
}
|
||||||
|
|
||||||
public: // StreamingReporterBase
|
public: // StreamingReporterBase
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE {
|
virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE {
|
||||||
@ -65,6 +71,8 @@ namespace Catch {
|
|||||||
.writeAttribute( "description", testInfo.description )
|
.writeAttribute( "description", testInfo.description )
|
||||||
.writeAttribute( "tags", testInfo.tagsAsString );
|
.writeAttribute( "tags", testInfo.tagsAsString );
|
||||||
|
|
||||||
|
writeSourceInfo( testInfo.lineInfo );
|
||||||
|
|
||||||
if ( m_config->showDurations() == ShowDurations::Always )
|
if ( m_config->showDurations() == ShowDurations::Always )
|
||||||
m_testCaseTimer.start();
|
m_testCaseTimer.start();
|
||||||
m_xml.ensureTagClosed();
|
m_xml.ensureTagClosed();
|
||||||
@ -76,6 +84,7 @@ namespace Catch {
|
|||||||
m_xml.startElement( "Section" )
|
m_xml.startElement( "Section" )
|
||||||
.writeAttribute( "name", trim( sectionInfo.name ) )
|
.writeAttribute( "name", trim( sectionInfo.name ) )
|
||||||
.writeAttribute( "description", sectionInfo.description );
|
.writeAttribute( "description", sectionInfo.description );
|
||||||
|
writeSourceInfo( sectionInfo.lineInfo );
|
||||||
m_xml.ensureTagClosed();
|
m_xml.ensureTagClosed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,9 +117,9 @@ namespace Catch {
|
|||||||
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( "type", assertionResult.getTestMacroName() );
|
||||||
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
|
||||||
.writeAttribute( "line", assertionResult.getSourceInfo().line );
|
writeSourceInfo( assertionResult.getSourceInfo() );
|
||||||
|
|
||||||
m_xml.scopedElement( "Original" )
|
m_xml.scopedElement( "Original" )
|
||||||
.writeText( assertionResult.getExpression() );
|
.writeText( assertionResult.getExpression() );
|
||||||
@ -121,16 +130,16 @@ namespace Catch {
|
|||||||
// And... Print a result applicable to each result type.
|
// 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.startElement( "Exception" );
|
||||||
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
writeSourceInfo( assertionResult.getSourceInfo() );
|
||||||
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
m_xml.writeText( assertionResult.getMessage() );
|
||||||
.writeText( assertionResult.getMessage() );
|
m_xml.endElement();
|
||||||
break;
|
break;
|
||||||
case ResultWas::FatalErrorCondition:
|
case ResultWas::FatalErrorCondition:
|
||||||
m_xml.scopedElement( "FatalErrorCondition" )
|
m_xml.startElement( "FatalErrorCondition" );
|
||||||
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
writeSourceInfo( assertionResult.getSourceInfo() );
|
||||||
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
m_xml.writeText( assertionResult.getMessage() );
|
||||||
.writeText( assertionResult.getMessage() );
|
m_xml.endElement();
|
||||||
break;
|
break;
|
||||||
case ResultWas::Info:
|
case ResultWas::Info:
|
||||||
m_xml.scopedElement( "Info" )
|
m_xml.scopedElement( "Info" )
|
||||||
@ -140,8 +149,10 @@ namespace Catch {
|
|||||||
// Warning will already have been written
|
// Warning will already have been written
|
||||||
break;
|
break;
|
||||||
case ResultWas::ExplicitFailure:
|
case ResultWas::ExplicitFailure:
|
||||||
m_xml.scopedElement( "Failure" )
|
m_xml.startElement( "Failure" );
|
||||||
.writeText( assertionResult.getMessage() );
|
writeSourceInfo( assertionResult.getSourceInfo() );
|
||||||
|
m_xml.writeText( assertionResult.getMessage() );
|
||||||
|
m_xml.endElement();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user