diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-21 12:10:32 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-24 00:52:01 +0200 |
commit | af7a3430edfc4deff494c9ec88b803f468b5cf2a (patch) | |
tree | 2ff7efa23349f7aea53a5525f45b0e6b8444b8d7 /src/testlib/qjunittestlogger.cpp | |
parent | 67c877562b18ea5c591d2884d2b14f7bf3a39149 (diff) |
testlib: Add start time and test duration to JUnit XML
As defined by https://llg.cubic.org/docs/junit/
Change-Id: Ic7683f3d49c529674f8467d591528d4a65d3add8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/testlib/qjunittestlogger.cpp')
-rw-r--r-- | src/testlib/qjunittestlogger.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/testlib/qjunittestlogger.cpp b/src/testlib/qjunittestlogger.cpp index 62cbac4164..bba1c777c5 100644 --- a/src/testlib/qjunittestlogger.cpp +++ b/src/testlib/qjunittestlogger.cpp @@ -81,6 +81,11 @@ void QJUnitTestLogger::startLogging() currentTestSuite = new QTestElement(QTest::LET_TestSuite); currentTestSuite->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName()); + auto localTime = QDateTime::currentDateTime(); + auto localTimeWithUtcOffset = localTime.toOffsetFromUtc(localTime.offsetFromUtc()); + currentTestSuite->addAttribute(QTest::AI_Timestamp, + localTimeWithUtcOffset.toString(Qt::ISODate).toUtf8().constData()); + QTestElement *property; QTestElement *properties = new QTestElement(QTest::LET_Properties); @@ -115,6 +120,9 @@ void QJUnitTestLogger::stopLogging() qsnprintf(buf, sizeof(buf), "%i", errorCounter); currentTestSuite->addAttribute(QTest::AI_Errors, buf); + currentTestSuite->addAttribute(QTest::AI_Time, + QByteArray::number(QTestLog::msecsTotalTime() / 1000, 'f').constData()); + currentTestSuite->addLogElement(listOfTestcases); // For correct indenting, make sure every testcase knows its parent @@ -147,6 +155,8 @@ void QJUnitTestLogger::enterTestFunction(const char *function) void QJUnitTestLogger::leaveTestFunction() { + currentLogElement->addAttribute(QTest::AI_Time, + QByteArray::number(QTestLog::msecsFunctionTime() / 1000, 'f').constData()); } void QJUnitTestLogger::addIncident(IncidentTypes type, const char *description, |