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

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorSean D. Cline2014-10-11 19:57:45 -0400
committerSean D. Cline2014-10-11 19:58:44 -0400
commitea81e98d6a01fc7858ac2339ddde90b7cb8162bd (patch)
treed1a44f41957a13e9f748c33d15b38afe0b30c13f /include
parentb0e53a8ee006cee203a40bf3c1454e8806135d9c (diff)
downloadcatch3-ea81e98d6a01fc7858ac2339ddde90b7cb8162bd.tar.gz
XmlReporter enhancement: Add attributes for duration when requested by the command line.
Diffstat (limited to 'include')
-rw-r--r--include/reporters/catch_reporter_xml.hpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp
index 6b31107a..530bb3c5 100644
--- a/include/reporters/catch_reporter_xml.hpp
+++ b/include/reporters/catch_reporter_xml.hpp
@@ -13,6 +13,7 @@
#include "../internal/catch_capture.hpp"
#include "../internal/catch_reporter_registrars.hpp"
#include "../internal/catch_xmlwriter.hpp"
+#include "../internal/catch_timer.h"
namespace Catch {
class XmlReporter : public StreamingReporterBase {
@@ -56,6 +57,9 @@ namespace Catch {
virtual void testCaseStarting( TestCaseInfo const& testInfo ) {
StreamingReporterBase::testCaseStarting(testInfo);
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
+
+ if ( m_config->showDurations() == ShowDurations::Always )
+ m_testCaseTimer.start();
}
virtual void sectionStarting( SectionInfo const& sectionInfo ) {
@@ -143,18 +147,26 @@ namespace Catch {
virtual void sectionEnded( SectionStats const& sectionStats ) {
StreamingReporterBase::sectionEnded( sectionStats );
if( --m_sectionDepth > 0 ) {
- m_xml.scopedElement( "OverallResults" )
- .writeAttribute( "successes", sectionStats.assertions.passed )
- .writeAttribute( "failures", sectionStats.assertions.failed )
- .writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk );
+ XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
+ e.writeAttribute( "successes", sectionStats.assertions.passed );
+ e.writeAttribute( "failures", sectionStats.assertions.failed );
+ e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk );
+
+ if ( m_config->showDurations() == ShowDurations::Always )
+ e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds );
+
m_xml.endElement();
}
}
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
StreamingReporterBase::testCaseEnded( testCaseStats );
- m_xml.scopedElement( "OverallResult" )
- .writeAttribute( "success", testCaseStats.totals.assertions.allPassed() );
+ XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
+ e.writeAttribute( "success", testCaseStats.totals.assertions.allPassed() );
+
+ if ( m_config->showDurations() == ShowDurations::Always )
+ e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() );
+
m_xml.endElement();
}
@@ -178,6 +190,7 @@ namespace Catch {
}
private:
+ Timer m_testCaseTimer;
XmlWriter m_xml;
int m_sectionDepth;
};