testlib: Gracefully handle messages outside of test function in JUnit reporter

Fixes: QTBUG-96543
Task-number: COIN-755
Pick-to: 6.2
Change-Id: I2334597319f3595f37f48c9811f667e57b99df28
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Tor Arne Vestbø 2021-09-16 10:17:02 +02:00
parent 040258b260
commit 8aa1fc6f12

View File

@ -308,6 +308,9 @@ void QJUnitTestLogger::addMessage(MessageTypes type, const QString &message, con
}
}();
if (!systemLogElement)
return; // FIXME: Handle messages outside of test functions
auto textNode = new QTestElement(QTest::LET_Text);
textNode->addAttribute(QTest::AI_Value, message.toUtf8().constData());
systemLogElement->addChild(textNode);