Improve JUnit failure report

The JUnit report is improved in that:
* The message shows the testing condition, not the result
* The actual message has similar output than the console one
This commit is contained in:
Alexander Stein 2019-08-07 22:39:01 +02:00 committed by Martin Hořeňovský
parent 51b29ced1a
commit 2fbd66c51c
2 changed files with 653 additions and 119 deletions

View File

@ -12,6 +12,7 @@
#include "../internal/catch_tostring.h" #include "../internal/catch_tostring.h"
#include "../internal/catch_reporter_registrars.hpp" #include "../internal/catch_reporter_registrars.hpp"
#include "../internal/catch_text.h"
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
@ -244,10 +245,25 @@ namespace Catch {
XmlWriter::ScopedElement e = xml.scopedElement( elementName ); XmlWriter::ScopedElement e = xml.scopedElement( elementName );
xml.writeAttribute( "message", result.getExpandedExpression() ); xml.writeAttribute( "message", result.getExpression() );
xml.writeAttribute( "type", result.getTestMacroName() ); xml.writeAttribute( "type", result.getTestMacroName() );
ReusableStringStream rss; ReusableStringStream rss;
if (stats.totals.assertions.total() > 0) {
rss << "FAILED" << ":\n";
if (result.hasExpression()) {
rss << " ";
rss << result.getExpressionInMacro();
rss << '\n';
}
if (result.hasExpandedExpression()) {
rss << "with expansion:\n";
rss << Column(result.getExpandedExpression()).indent(2) << '\n';
}
} else {
rss << '\n';
}
if( !result.getMessage().empty() ) if( !result.getMessage().empty() )
rss << result.getMessage() << '\n'; rss << result.getMessage() << '\n';
for( auto const& msg : stats.infoMessages ) for( auto const& msg : stats.infoMessages )

File diff suppressed because it is too large Load Diff