mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Tweaked Xml Reporter to follow same success/ info behaviour as Console reporter
This commit is contained in:
parent
be4f6ab8e1
commit
9bee606dd6
@ -92,10 +92,13 @@ namespace Catch {
|
|||||||
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { }
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { }
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
|
||||||
|
|
||||||
|
AssertionResult const& result = assertionStats.assertionResult;
|
||||||
|
|
||||||
|
bool includeResults = m_config->includeSuccessfulResults() || result.isOk();
|
||||||
|
|
||||||
|
if( includeResults ) {
|
||||||
// Print any info messages in <Info> tags.
|
// 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();
|
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
@ -110,55 +113,56 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Drop out if result was successful but we're not printing them.
|
// Drop out if result was successful but we're not printing them.
|
||||||
if( !m_config->includeSuccessfulResults() && isOk(assertionResult.getResultType()) )
|
if( !includeResults && result.getResultType() != ResultWas::Warning )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Print the expression if there is one.
|
|
||||||
if( assertionResult.hasExpression() ) {
|
|
||||||
m_xml.startElement( "Expression" )
|
|
||||||
.writeAttribute( "success", assertionResult.succeeded() )
|
|
||||||
.writeAttribute( "type", assertionResult.getTestMacroName() );
|
|
||||||
|
|
||||||
writeSourceInfo( assertionResult.getSourceInfo() );
|
// Print the expression if there is one.
|
||||||
|
if( result.hasExpression() ) {
|
||||||
|
m_xml.startElement( "Expression" )
|
||||||
|
.writeAttribute( "success", result.succeeded() )
|
||||||
|
.writeAttribute( "type", result.getTestMacroName() );
|
||||||
|
|
||||||
|
writeSourceInfo( result.getSourceInfo() );
|
||||||
|
|
||||||
m_xml.scopedElement( "Original" )
|
m_xml.scopedElement( "Original" )
|
||||||
.writeText( assertionResult.getExpression() );
|
.writeText( result.getExpression() );
|
||||||
m_xml.scopedElement( "Expanded" )
|
m_xml.scopedElement( "Expanded" )
|
||||||
.writeText( assertionResult.getExpandedExpression() );
|
.writeText( result.getExpandedExpression() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// And... Print a result applicable to each result type.
|
// And... Print a result applicable to each result type.
|
||||||
switch( assertionResult.getResultType() ) {
|
switch( result.getResultType() ) {
|
||||||
case ResultWas::ThrewException:
|
case ResultWas::ThrewException:
|
||||||
m_xml.startElement( "Exception" );
|
m_xml.startElement( "Exception" );
|
||||||
writeSourceInfo( assertionResult.getSourceInfo() );
|
writeSourceInfo( result.getSourceInfo() );
|
||||||
m_xml.writeText( assertionResult.getMessage() );
|
m_xml.writeText( result.getMessage() );
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
break;
|
break;
|
||||||
case ResultWas::FatalErrorCondition:
|
case ResultWas::FatalErrorCondition:
|
||||||
m_xml.startElement( "FatalErrorCondition" );
|
m_xml.startElement( "FatalErrorCondition" );
|
||||||
writeSourceInfo( assertionResult.getSourceInfo() );
|
writeSourceInfo( result.getSourceInfo() );
|
||||||
m_xml.writeText( assertionResult.getMessage() );
|
m_xml.writeText( result.getMessage() );
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
break;
|
break;
|
||||||
case ResultWas::Info:
|
case ResultWas::Info:
|
||||||
m_xml.scopedElement( "Info" )
|
m_xml.scopedElement( "Info" )
|
||||||
.writeText( assertionResult.getMessage() );
|
.writeText( result.getMessage() );
|
||||||
break;
|
break;
|
||||||
case ResultWas::Warning:
|
case ResultWas::Warning:
|
||||||
// Warning will already have been written
|
// Warning will already have been written
|
||||||
break;
|
break;
|
||||||
case ResultWas::ExplicitFailure:
|
case ResultWas::ExplicitFailure:
|
||||||
m_xml.startElement( "Failure" );
|
m_xml.startElement( "Failure" );
|
||||||
writeSourceInfo( assertionResult.getSourceInfo() );
|
writeSourceInfo( result.getSourceInfo() );
|
||||||
m_xml.writeText( assertionResult.getMessage() );
|
m_xml.writeText( result.getMessage() );
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( assertionResult.hasExpression() )
|
if( result.hasExpression() )
|
||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -645,6 +645,9 @@
|
|||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Capture and info messages" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
<TestCase name="Capture and info messages" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||||
<Section name="Capture should stringify like assertions" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
<Section name="Capture should stringify like assertions" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||||
|
<Info>
|
||||||
|
i := 2
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
true
|
true
|
||||||
@ -656,6 +659,9 @@
|
|||||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||||
</Section>
|
</Section>
|
||||||
<Section name="Info should NOT stringify the way assertions do" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
<Section name="Info should NOT stringify the way assertions do" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||||
|
<Info>
|
||||||
|
3
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
true
|
true
|
||||||
@ -2632,6 +2638,9 @@
|
|||||||
<OverallResult success="false"/>
|
<OverallResult success="false"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="INFO gets logged on failure, even if captured before successful assertions" tags="[.][failing][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
<TestCase name="INFO gets logged on failure, even if captured before successful assertions" tags="[.][failing][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
|
<Info>
|
||||||
|
this message may be logged later
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
a == 2
|
a == 2
|
||||||
@ -2662,6 +2671,9 @@
|
|||||||
2 == 0
|
2 == 0
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
but not this
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
a == 2
|
a == 2
|
||||||
@ -6761,6 +6773,12 @@ re>"
|
|||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="SCOPED_INFO is reset for each loop" tags="[.][failing][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
<TestCase name="SCOPED_INFO is reset for each loop" tags="[.][failing][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
|
<Info>
|
||||||
|
current counter 0
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 0
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6769,6 +6787,12 @@ re>"
|
|||||||
0 < 10
|
0 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 1
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 1
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6777,6 +6801,12 @@ re>"
|
|||||||
1 < 10
|
1 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 2
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 2
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6785,6 +6815,12 @@ re>"
|
|||||||
2 < 10
|
2 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 3
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 3
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6793,6 +6829,12 @@ re>"
|
|||||||
3 < 10
|
3 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 4
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 4
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6801,6 +6843,12 @@ re>"
|
|||||||
4 < 10
|
4 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 5
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 5
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6809,6 +6857,12 @@ re>"
|
|||||||
5 < 10
|
5 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 6
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 6
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6817,6 +6871,12 @@ re>"
|
|||||||
6 < 10
|
6 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 7
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 7
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6825,6 +6885,12 @@ re>"
|
|||||||
7 < 10
|
7 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 8
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 8
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -6833,6 +6899,12 @@ re>"
|
|||||||
8 < 10
|
8 < 10
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
current counter 9
|
||||||
|
</Info>
|
||||||
|
<Info>
|
||||||
|
i := 9
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
i < 10
|
i < 10
|
||||||
@ -9111,6 +9183,9 @@ spanner <OverallResult success="true"/>
|
|||||||
1 == 0
|
1 == 0
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
Testing if fib[2] (2) is even
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
( fib[i] % 2 ) == 0
|
( fib[i] % 2 ) == 0
|
||||||
@ -9141,6 +9216,9 @@ spanner <OverallResult success="true"/>
|
|||||||
1 == 0
|
1 == 0
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Info>
|
||||||
|
Testing if fib[5] (8) is even
|
||||||
|
</Info>
|
||||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
( fib[i] % 2 ) == 0
|
( fib[i] % 2 ) == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user