mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-05 03:23:29 +01:00
JUnit reporter: Added ISO8601 timestamp to the timestamp attribute.
This commit is contained in:
parent
7eb5acc183
commit
c268cea41d
@ -15,6 +15,7 @@
|
||||
#include "../internal/catch_xmlwriter.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctime>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -86,7 +87,17 @@ namespace Catch {
|
||||
xml.writeAttribute( "time", "" );
|
||||
else
|
||||
xml.writeAttribute( "time", suiteTime );
|
||||
xml.writeAttribute( "timestamp", "tbd" ); // !TBD
|
||||
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
const size_t timestampLength = 33;
|
||||
char iso8601Timestamp[timestampLength];
|
||||
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
strftime (iso8601Timestamp,timestampLength, "%Y-%m-%dT%T%z", timeinfo);
|
||||
xml.writeAttribute( "timestamp", iso8601Timestamp );
|
||||
|
||||
// Write test cases
|
||||
for( TestGroupNode::ChildNodes::const_iterator
|
||||
@ -108,7 +119,7 @@ namespace Catch {
|
||||
SectionNode const& rootSection = *testCaseNode.children.front();
|
||||
|
||||
std::string className = stats.testInfo.className;
|
||||
|
||||
|
||||
if( className.empty() ) {
|
||||
if( rootSection.childSections.empty() )
|
||||
className = "global";
|
||||
@ -122,7 +133,7 @@ namespace Catch {
|
||||
std::string name = trim( sectionNode.stats.sectionInfo.name );
|
||||
if( !rootName.empty() )
|
||||
name = rootName + "/" + name;
|
||||
|
||||
|
||||
if( !sectionNode.assertions.empty() ||
|
||||
!sectionNode.stdOut.empty() ||
|
||||
!sectionNode.stdErr.empty() ) {
|
||||
@ -190,7 +201,7 @@ namespace Catch {
|
||||
elementName = "internalError";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
XmlWriter::ScopedElement e = xml.scopedElement( elementName );
|
||||
|
||||
xml.writeAttribute( "message", result.getExpandedExpression() );
|
||||
@ -219,7 +230,7 @@ namespace Catch {
|
||||
unsigned int unexpectedExceptions;
|
||||
};
|
||||
|
||||
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
|
||||
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user