summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestjunitstreamer.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-02 14:29:28 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-06 17:00:22 +0200
commita2026e4116e325767b899505cf248a75b9647195 (patch)
tree3017b370a33d93bebfd3b91ad82e7c7d5aa1c711 /src/testlib/qtestjunitstreamer.cpp
parent0ce70a29b36a43f08ff3c8cdecde7ea75af0840f (diff)
testlib: Write failure details as <failure> content in JUnit reporter
Pick-to: 6.2 Change-Id: Ica48769e7dfcabdc4bc8f0ed058bc22e29a0b632 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/testlib/qtestjunitstreamer.cpp')
-rw-r--r--src/testlib/qtestjunitstreamer.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/testlib/qtestjunitstreamer.cpp b/src/testlib/qtestjunitstreamer.cpp
index 96757f0768..8176205cbb 100644
--- a/src/testlib/qtestjunitstreamer.cpp
+++ b/src/testlib/qtestjunitstreamer.cpp
@@ -83,11 +83,13 @@ void QTestJUnitStreamer::formatStart(const QTestElement *element, QTestCharBuffe
indentForElement(element, indent, sizeof(indent));
// Messages/errors are written as CDATA within system-out, system-err,
- // respectively, comments elsewhere
+ // error, and failure respectively, comments elsewhere
if (element->elementType() == QTest::LET_Message) {
switch (element->parentElement()->elementType()) {
case QTest::LET_SystemOutput:
case QTest::LET_SystemError:
+ case QTest::LET_Failure:
+ case QTest::LET_Error:
QTest::qt_asprintf(formatted, "%s<![CDATA[", indent);
break;
default:
@@ -123,11 +125,12 @@ void QTestJUnitStreamer::formatAttributes(const QTestElement* element, const QTe
QTest::AttributeIndex attrindex = attribute->index();
- // For messages/errors within system-out, system-err, respectively,
- // we only want to output `message'
+ // For messages we only want to output the `message' attribute value
if (element && element->elementType() == QTest::LET_Message
&& (element->parentElement()->elementType() == QTest::LET_SystemOutput
- || element->parentElement()->elementType() == QTest::LET_SystemError)) {
+ || element->parentElement()->elementType() == QTest::LET_SystemError
+ || element->parentElement()->elementType() == QTest::LET_Failure
+ || element->parentElement()->elementType() == QTest::LET_Error)) {
if (attrindex != QTest::AI_Message) return;
@@ -146,12 +149,14 @@ void QTestJUnitStreamer::formatAfterAttributes(const QTestElement *element, QTes
if (!element || !formatted )
return;
- // Messages/errors are written as CDATA within system-out, system-err,
- // respectively, comments elsewhere
+ // Messages are written as CDATA within system-out, system-err,
+ // error, and failure respectively, comments elsewhere
if (element->elementType() == QTest::LET_Message) {
switch (element->parentElement()->elementType()) {
case QTest::LET_SystemOutput:
case QTest::LET_SystemError:
+ case QTest::LET_Failure:
+ case QTest::LET_Error:
QTest::qt_asprintf(formatted, "]]>\n");
break;
default: