diff options
| author | Martin Hořeňovský | 2021-06-07 19:53:34 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-10-10 22:21:39 +0200 |
| commit | b406ad52a77c3f59e1880ff64d5f3ed4e962364d (patch) | |
| tree | d5a17526bfa5b9c6e65e254db842ca84ac2c8a47 /src | |
| parent | de67278e145bf0d5d4ceb3e2bdcf42fda5b4876d (diff) | |
| download | catch3-b406ad52a77c3f59e1880ff64d5f3ed4e962364d.tar.gz | |
Mark !mayfail tests as skipped in the JUnit reporter
Should fix #2116
Diffstat (limited to 'src')
| -rw-r--r-- | src/catch2/reporters/catch_reporter_junit.cpp | 19 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_junit.hpp | 3 |
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); |