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.
This commit is contained in:
Thomas Sondergaard 2017-05-30 17:26:46 +02:00
parent a64a0c6f06
commit a6b03031ba
1 changed files with 10 additions and 1 deletions

View File

@ -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 );
}