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

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorThomas Sondergaard2017-05-30 17:26:46 +0200
committerThomas Sondergaard2017-06-05 12:51:56 +0200
commita6b03031ba56ffda9c2b655ac2d17ed9d49e3659 (patch)
treefc02630598fb591b203a764188a40f98b7e1ae1d /include
parenta64a0c6f06bd766896c84cbad5559454bbf9b84e (diff)
downloadcatch3-a6b03031ba56ffda9c2b655ac2d17ed9d49e3659.tar.gz
Use [#filename] tag for junit testcase classname attribute
If [#filename] is present in tags, use it for the classname attribute, rather than "global". If the test fixture is present that still takes precedence.
Diffstat (limited to 'include')
-rw-r--r--include/reporters/catch_reporter_junit.hpp11
1 files changed, 10 insertions, 1 deletions
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<std::string> &tags ) {
+ std::set<std::string>::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 );
}