diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp index c8f1238e..2b5a9bd5 100644 --- a/include/reporters/catch_reporter_junit.hpp +++ b/include/reporters/catch_reporter_junit.hpp @@ -128,6 +128,13 @@ namespace Catch { xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite.str() ), false ); } + static std::string fileNameTag( const std::set &tags ) { + std::set::const_iterator it = tags.lower_bound("#"); + if( it != tags.end() && !it->empty() && it->front() == '#' ) + return it->substr(1); + return std::string(); + } + void writeTestCase( TestCaseNode const& testCaseNode ) { TestCaseStats const& stats = testCaseNode.value; @@ -139,7 +146,9 @@ namespace Catch { std::string className = stats.testInfo.className; if( className.empty() ) { - className = "global"; + className = fileNameTag(stats.testInfo.tags); + if ( className.empty() ) + className = "global"; } writeSection( className, "", rootSection ); }