testlib: Fix name of current test case element in JUnit reporter
Pick-to: 6.2 Change-Id: I0bd77e5f1d0540b87568a0c69a4b96442d4000eb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
a2026e4116
commit
1272b60d9e
@ -172,10 +172,10 @@ void QJUnitTestLogger::enterTestFunction(const char *function)
|
|||||||
|
|
||||||
void QJUnitTestLogger::enterTestCase(const char *name)
|
void QJUnitTestLogger::enterTestCase(const char *name)
|
||||||
{
|
{
|
||||||
currentLogElement = new QTestElement(QTest::LET_TestCase);
|
currentTestCase = new QTestElement(QTest::LET_TestCase);
|
||||||
currentLogElement->addAttribute(QTest::AI_Name, name);
|
currentTestCase->addAttribute(QTest::AI_Name, name);
|
||||||
currentLogElement->addAttribute(QTest::AI_Classname, QTestResult::currentTestObjectName());
|
currentTestCase->addAttribute(QTest::AI_Classname, QTestResult::currentTestObjectName());
|
||||||
currentLogElement->addToList(&listOfTestcases);
|
currentTestCase->addToList(&listOfTestcases);
|
||||||
|
|
||||||
// The element will be deleted when the suite is deleted
|
// The element will be deleted when the suite is deleted
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ void QJUnitTestLogger::enterTestData(QTestData *)
|
|||||||
if (QTestResult::currentTestFunction() != lastTestFunction) {
|
if (QTestResult::currentTestFunction() != lastTestFunction) {
|
||||||
// Adopt existing testcase for the initial test data
|
// Adopt existing testcase for the initial test data
|
||||||
auto *name = const_cast<QTestElementAttribute*>(
|
auto *name = const_cast<QTestElementAttribute*>(
|
||||||
currentLogElement->attribute(QTest::AI_Name));
|
currentTestCase->attribute(QTest::AI_Name));
|
||||||
name->setPair(QTest::AI_Name, testIdentifier.data());
|
name->setPair(QTest::AI_Name, testIdentifier.data());
|
||||||
lastTestFunction = QTestResult::currentTestFunction();
|
lastTestFunction = QTestResult::currentTestFunction();
|
||||||
elapsedTestcaseTime.restart();
|
elapsedTestcaseTime.restart();
|
||||||
@ -212,7 +212,7 @@ void QJUnitTestLogger::leaveTestFunction()
|
|||||||
|
|
||||||
void QJUnitTestLogger::leaveTestCase()
|
void QJUnitTestLogger::leaveTestCase()
|
||||||
{
|
{
|
||||||
currentLogElement->addAttribute(QTest::AI_Time,
|
currentTestCase->addAttribute(QTest::AI_Time,
|
||||||
toSecondsFormat(elapsedTestCaseSeconds()).constData());
|
toSecondsFormat(elapsedTestCaseSeconds()).constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ void QJUnitTestLogger::addIncident(IncidentTypes type, const char *description,
|
|||||||
failureElement->addLogElement(messageElement);
|
failureElement->addLogElement(messageElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentLogElement->addLogElement(failureElement);
|
currentTestCase->addLogElement(failureElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -292,7 +292,7 @@ void QJUnitTestLogger::addMessage(MessageTypes type, const QString &message, con
|
|||||||
if (type == QAbstractTestLogger::Skip) {
|
if (type == QAbstractTestLogger::Skip) {
|
||||||
auto skippedElement = new QTestElement(QTest::LET_Skipped);
|
auto skippedElement = new QTestElement(QTest::LET_Skipped);
|
||||||
skippedElement->addAttribute(QTest::AI_Message, message.toUtf8().constData());
|
skippedElement->addAttribute(QTest::AI_Message, message.toUtf8().constData());
|
||||||
currentLogElement->addLogElement(skippedElement);
|
currentTestCase->addLogElement(skippedElement);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ void QJUnitTestLogger::addMessage(MessageTypes type, const QString &message, con
|
|||||||
messageElement->addAttribute(QTest::AI_Type, typeBuf);
|
messageElement->addAttribute(QTest::AI_Type, typeBuf);
|
||||||
messageElement->addAttribute(QTest::AI_Message, message.toUtf8().constData());
|
messageElement->addAttribute(QTest::AI_Message, message.toUtf8().constData());
|
||||||
|
|
||||||
currentLogElement->addLogElement(messageElement);
|
currentTestCase->addLogElement(messageElement);
|
||||||
|
|
||||||
// Also add the message to the system log (stdout/stderr), if one exists
|
// Also add the message to the system log (stdout/stderr), if one exists
|
||||||
if (systemLogElement) {
|
if (systemLogElement) {
|
||||||
|
@ -85,7 +85,7 @@ class QJUnitTestLogger : public QAbstractTestLogger
|
|||||||
|
|
||||||
QTestElement *currentTestSuite = nullptr;
|
QTestElement *currentTestSuite = nullptr;
|
||||||
QTestElement *listOfTestcases = nullptr;
|
QTestElement *listOfTestcases = nullptr;
|
||||||
QTestElement *currentLogElement = nullptr;
|
QTestElement *currentTestCase = nullptr;
|
||||||
QTestElement *systemOutputElement = nullptr;
|
QTestElement *systemOutputElement = nullptr;
|
||||||
QTestElement *systemErrorElement = nullptr;
|
QTestElement *systemErrorElement = nullptr;
|
||||||
QTestJUnitStreamer *logFormatter = nullptr;
|
QTestJUnitStreamer *logFormatter = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user