diff --git a/src/plugins/autotest/catch/catchconfiguration.cpp b/src/plugins/autotest/catch/catchconfiguration.cpp index e1773064f77..0012ad71dc5 100644 --- a/src/plugins/autotest/catch/catchconfiguration.cpp +++ b/src/plugins/autotest/catch/catchconfiguration.cpp @@ -76,7 +76,7 @@ QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) con QStringList arguments; if (testCaseCount()) arguments << "\"" + testCases().join("\", \"") + "\""; - arguments << "--reporter" << "xml"; + arguments << "--reporter" << "xml" << "--durations" << "yes"; if (testSettings().processArgs()) { arguments << filterInterfering(runnable().command.arguments().split( diff --git a/src/plugins/autotest/catch/catchoutputreader.cpp b/src/plugins/autotest/catch/catchoutputreader.cpp index 6c730c30455..ccd28465f6b 100644 --- a/src/plugins/autotest/catch/catchoutputreader.cpp +++ b/src/plugins/autotest/catch/catchoutputreader.cpp @@ -67,6 +67,12 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin recordTestInformation(m_xmlReader.attributes()); sendResult(ResultType::TestStart); } else if (m_currentTagName == CatchXml::TestCaseResultElement) { + const QXmlStreamAttributes attributes = m_xmlReader.attributes(); + if (attributes.hasAttribute("durationInSeconds")) { + double durationInSec = attributes.value("durationInSeconds").toDouble(); + m_duration = durationInSec * 1000.; + m_overallDuration += m_duration; + } if (m_currentTestNode == OverallNode || m_currentTestNode == GroupNode) continue; if (m_reportedResult) @@ -88,6 +94,7 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin if (m_xpassCount) m_summary[ResultType::UnexpectedPass] = m_xpassCount; } + m_executionDuration = qRound(m_overallDuration); if (m_currentTestNode == OverallNode || m_currentTestNode == GroupNode) continue; if (attributes.value("failures").toInt() == 0) @@ -142,9 +149,11 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin if (currentTag == QLatin1String(CatchXml::SectionElement)) { sendResult(ResultType::TestEnd); + m_duration = 0; testOutputNodeFinished(SectionNode); } else if (currentTag == QLatin1String(CatchXml::TestCaseElement)) { sendResult(ResultType::TestEnd); + m_duration = 0; testOutputNodeFinished(TestCaseNode); } else if (currentTag == QLatin1String(CatchXml::GroupElement)) { testOutputNodeFinished(GroupNode); @@ -262,6 +271,7 @@ void CatchOutputReader::sendResult(const ResultType result) m_reportedSectionResult = true; m_reportedResult = true; } else if (result == ResultType::TestEnd) { + catchResult.setDuration(QString::number(m_duration, 'f', 3)); catchResult.setDescription(Tr::tr("Finished executing %1 \"%2\".") .arg(testOutputNodeToString().toLower(), catchResult.description())); } else if (result == ResultType::Benchmark || result == ResultType::MessageFatal) { diff --git a/src/plugins/autotest/catch/catchoutputreader.h b/src/plugins/autotest/catch/catchoutputreader.h index b46db333f80..5ff474d77f2 100644 --- a/src/plugins/autotest/catch/catchoutputreader.h +++ b/src/plugins/autotest/catch/catchoutputreader.h @@ -55,6 +55,8 @@ private: QXmlStreamReader m_xmlReader; ResultType m_currentResult = ResultType::Invalid; int m_xpassCount = 0; + double m_duration = 0; // in ms + double m_overallDuration = 0; // in ms bool m_mayFail = false; bool m_shouldFail = false; bool m_reportedResult = false;