Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-06-07 19:53:34 +0200
committerMartin Hořeňovský2021-10-10 22:21:39 +0200
commitb406ad52a77c3f59e1880ff64d5f3ed4e962364d (patch)
treed5a17526bfa5b9c6e65e254db842ca84ac2c8a47 /src/catch2
parentde67278e145bf0d5d4ceb3e2bdcf42fda5b4876d (diff)
downloadcatch3-b406ad52a77c3f59e1880ff64d5f3ed4e962364d.tar.gz
Mark !mayfail tests as skipped in the JUnit reporter
Should fix #2116
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/reporters/catch_reporter_junit.cpp19
-rw-r--r--src/catch2/reporters/catch_reporter_junit.hpp3
2 files changed, 15 insertions, 7 deletions
diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp
index 71a93051..00b00b47 100644
--- a/src/catch2/reporters/catch_reporter_junit.cpp
+++ b/src/catch2/reporters/catch_reporter_junit.cpp
@@ -168,12 +168,13 @@ namespace Catch {
if ( !m_config->name().empty() )
className = static_cast<std::string>(m_config->name()) + '.' + className;
- writeSection( className, "", rootSection );
+ writeSection( className, "", rootSection, stats.testInfo->okToFail() );
}
- void JunitReporter::writeSection( std::string const& className,
- std::string const& rootName,
- SectionNode const& sectionNode ) {
+ void JunitReporter::writeSection( std::string const& className,
+ std::string const& rootName,
+ SectionNode const& sectionNode,
+ bool testOkToFail) {
std::string name = trim( sectionNode.stats.sectionInfo.name );
if( !rootName.empty() )
name = rootName + '/' + name;
@@ -197,8 +198,14 @@ namespace Catch {
// events and write those out appropriately.
xml.writeAttribute( "status"_sr, "run"_sr );
+ if (sectionNode.stats.assertions.failedButOk) {
+ xml.scopedElement("skipped")
+ .writeAttribute("message", "TEST_CASE tagged with !mayfail");
+ }
+
writeAssertions( sectionNode );
+
if( !sectionNode.stdOut.empty() )
xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), XmlFormatting::Newline );
if( !sectionNode.stdErr.empty() )
@@ -206,9 +213,9 @@ namespace Catch {
}
for( auto const& childNode : sectionNode.childSections )
if( className.empty() )
- writeSection( name, "", *childNode );
+ writeSection( name, "", *childNode, testOkToFail );
else
- writeSection( className, name, *childNode );
+ writeSection( className, name, *childNode, testOkToFail );
}
void JunitReporter::writeAssertions( SectionNode const& sectionNode ) {
diff --git a/src/catch2/reporters/catch_reporter_junit.hpp b/src/catch2/reporters/catch_reporter_junit.hpp
index 6665663c..6991c224 100644
--- a/src/catch2/reporters/catch_reporter_junit.hpp
+++ b/src/catch2/reporters/catch_reporter_junit.hpp
@@ -39,7 +39,8 @@ namespace Catch {
void writeSection( std::string const& className,
std::string const& rootName,
- SectionNode const& sectionNode );
+ SectionNode const& sectionNode,
+ bool testOkToFail );
void writeAssertions(SectionNode const& sectionNode);
void writeAssertion(AssertionStats const& stats);