summaryrefslogtreecommitdiffstats
path: root/src/testlib/qxmltestlogger.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-10-24 20:10:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-13 07:13:17 +0100
commit019588f30792132d9eca5dab11278547b287804e (patch)
tree87ef85ac726dac5235e13f45e28a811611555035 /src/testlib/qxmltestlogger.cpp
parent19be46414ae68c619b94f2fdebd21192898d65fd (diff)
Testlib: Add test duration to xml output
[ChangeLog][QtTest] Added test duration to xml output. When running tests with xml output a new tag of the form <duration msecs="123"/> is added to each test function and the test as a whole. Change-Id: Ibc4db066b6acf5fac6c578f5e5ca5ce4b5d8ea8e Reviewed-by: Sergio Ahumada <sahumada@blackberry.com> Reviewed-by: Jason McDonald <macadder1@gmail.com>
Diffstat (limited to 'src/testlib/qxmltestlogger.cpp')
-rw-r--r--src/testlib/qxmltestlogger.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp
index 3f77f152b5..b4035301d3 100644
--- a/src/testlib/qxmltestlogger.cpp
+++ b/src/testlib/qxmltestlogger.cpp
@@ -121,10 +121,16 @@ void QXmlTestLogger::startLogging()
" <QTestVersion>" QTEST_VERSION_STR "</QTestVersion>\n"
"</Environment>\n", qVersion());
outputString(buf.constData());
+ m_totalTime.start();
}
void QXmlTestLogger::stopLogging()
{
+ QTestCharBuffer buf;
+ QTest::qt_asprintf(&buf,
+ "<Duration msecs=\"%f\"/>\n",
+ m_totalTime.nsecsElapsed() / 1000000.);
+ outputString(buf.constData());
if (xmlmode == QXmlTestLogger::Complete) {
outputString("</TestCase>\n");
}
@@ -139,11 +145,19 @@ void QXmlTestLogger::enterTestFunction(const char *function)
xmlQuote(&quotedFunction, function);
QTest::qt_asprintf(&buf, "<TestFunction name=\"%s\">\n", quotedFunction.constData());
outputString(buf.constData());
+
+ m_functionTime.start();
}
void QXmlTestLogger::leaveTestFunction()
{
- outputString("</TestFunction>\n");
+ QTestCharBuffer buf;
+ QTest::qt_asprintf(&buf,
+ " <Duration msecs=\"%f\"/>\n"
+ "</TestFunction>\n",
+ m_functionTime.nsecsElapsed() / 1000000.);
+
+ outputString(buf.constData());
}
namespace QTest