forked from qt-creator/qt-creator
Make test result distinguishable more easily
This additionally fixes the output of the gtest related test cases. Change-Id: Ia9e19604ffe387752b08db4a4ad9a9e255d210a3 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
@@ -183,14 +183,14 @@ void TestOutputReader::processOutput()
|
|||||||
if (currentTag == QStringLiteral("TestCase")) {
|
if (currentTag == QStringLiteral("TestCase")) {
|
||||||
className = xmlReader.attributes().value(QStringLiteral("name")).toString();
|
className = xmlReader.attributes().value(QStringLiteral("name")).toString();
|
||||||
QTC_ASSERT(!className.isEmpty(), continue);
|
QTC_ASSERT(!className.isEmpty(), continue);
|
||||||
auto testResult = new TestResult(className);
|
auto testResult = new QTestResult(className);
|
||||||
testResult->setResult(Result::MessageTestCaseStart);
|
testResult->setResult(Result::MessageTestCaseStart);
|
||||||
testResult->setDescription(tr("Executing test case %1").arg(className));
|
testResult->setDescription(tr("Executing test case %1").arg(className));
|
||||||
testResultCreated(testResult);
|
testResultCreated(testResult);
|
||||||
} else if (currentTag == QStringLiteral("TestFunction")) {
|
} else if (currentTag == QStringLiteral("TestFunction")) {
|
||||||
testCase = xmlReader.attributes().value(QStringLiteral("name")).toString();
|
testCase = xmlReader.attributes().value(QStringLiteral("name")).toString();
|
||||||
QTC_ASSERT(!testCase.isEmpty(), continue);
|
QTC_ASSERT(!testCase.isEmpty(), continue);
|
||||||
auto testResult = new TestResult();
|
auto testResult = new QTestResult();
|
||||||
testResult->setResult(Result::MessageCurrentTest);
|
testResult->setResult(Result::MessageCurrentTest);
|
||||||
testResult->setDescription(tr("Entering test function %1::%2").arg(className,
|
testResult->setDescription(tr("Entering test function %1::%2").arg(className,
|
||||||
testCase));
|
testCase));
|
||||||
@@ -274,7 +274,7 @@ void TestOutputReader::processOutput()
|
|||||||
const QStringRef currentTag = xmlReader.name();
|
const QStringRef currentTag = xmlReader.name();
|
||||||
if (currentTag == QStringLiteral("TestFunction")) {
|
if (currentTag == QStringLiteral("TestFunction")) {
|
||||||
if (!duration.isEmpty()) {
|
if (!duration.isEmpty()) {
|
||||||
auto testResult = new TestResult(className);
|
auto testResult = new QTestResult(className);
|
||||||
testResult->setTestCase(testCase);
|
testResult->setTestCase(testCase);
|
||||||
testResult->setResult(Result::MessageInternal);
|
testResult->setResult(Result::MessageInternal);
|
||||||
testResult->setDescription(tr("Execution took %1 ms.").arg(duration));
|
testResult->setDescription(tr("Execution took %1 ms.").arg(duration));
|
||||||
@@ -282,14 +282,14 @@ void TestOutputReader::processOutput()
|
|||||||
}
|
}
|
||||||
emit increaseProgress();
|
emit increaseProgress();
|
||||||
} else if (currentTag == QStringLiteral("TestCase")) {
|
} else if (currentTag == QStringLiteral("TestCase")) {
|
||||||
auto testResult = new TestResult(className);
|
auto testResult = new QTestResult(className);
|
||||||
testResult->setResult(Result::MessageTestCaseEnd);
|
testResult->setResult(Result::MessageTestCaseEnd);
|
||||||
testResult->setDescription(
|
testResult->setDescription(
|
||||||
duration.isEmpty() ? tr("Test finished.")
|
duration.isEmpty() ? tr("Test finished.")
|
||||||
: tr("Test execution took %1 ms.").arg(duration));
|
: tr("Test execution took %1 ms.").arg(duration));
|
||||||
testResultCreated(testResult);
|
testResultCreated(testResult);
|
||||||
} else if (validEndTags.contains(currentTag.toString())) {
|
} else if (validEndTags.contains(currentTag.toString())) {
|
||||||
auto testResult = new TestResult(className);
|
auto testResult = new QTestResult(className);
|
||||||
testResult->setTestCase(testCase);
|
testResult->setTestCase(testCase);
|
||||||
testResult->setDataTag(dataTag);
|
testResult->setDataTag(dataTag);
|
||||||
testResult->setResult(result);
|
testResult->setResult(result);
|
||||||
@@ -337,13 +337,13 @@ void TestOutputReader::processGTestOutput()
|
|||||||
if (!line.startsWith(QLatin1Char('['))) {
|
if (!line.startsWith(QLatin1Char('['))) {
|
||||||
description.append(line).append(QLatin1Char('\n'));
|
description.append(line).append(QLatin1Char('\n'));
|
||||||
if (line.startsWith(QStringLiteral("Note:"))) {
|
if (line.startsWith(QStringLiteral("Note:"))) {
|
||||||
auto testResult = new TestResult();
|
auto testResult = new GTestResult();
|
||||||
testResult->setResult(Result::MessageInternal);
|
testResult->setResult(Result::MessageInternal);
|
||||||
testResult->setDescription(line);
|
testResult->setDescription(line);
|
||||||
testResultCreated(testResult);
|
testResultCreated(testResult);
|
||||||
description.clear();
|
description.clear();
|
||||||
} else if (disabledTests.exactMatch(line)) {
|
} else if (disabledTests.exactMatch(line)) {
|
||||||
auto testResult = new TestResult();
|
auto testResult = new GTestResult();
|
||||||
testResult->setResult(Result::MessageInternal);
|
testResult->setResult(Result::MessageInternal);
|
||||||
int disabled = disabledTests.cap(1).toInt();
|
int disabled = disabledTests.cap(1).toInt();
|
||||||
testResult->setDescription(tr("You have %n disabled test(s).", 0, disabled));
|
testResult->setDescription(tr("You have %n disabled test(s).", 0, disabled));
|
||||||
@@ -354,7 +354,7 @@ void TestOutputReader::processGTestOutput()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (testEnds.exactMatch(line)) {
|
if (testEnds.exactMatch(line)) {
|
||||||
auto testResult = new TestResult(currentTestName);
|
auto testResult = new GTestResult(currentTestName);
|
||||||
testResult->setTestCase(currentTestSet);
|
testResult->setTestCase(currentTestSet);
|
||||||
testResult->setResult(Result::MessageTestCaseEnd);
|
testResult->setResult(Result::MessageTestCaseEnd);
|
||||||
testResult->setDescription(tr("Test execution took %1").arg(testEnds.cap(2)));
|
testResult->setDescription(tr("Test execution took %1").arg(testEnds.cap(2)));
|
||||||
@@ -363,29 +363,29 @@ void TestOutputReader::processGTestOutput()
|
|||||||
currentTestSet.clear();
|
currentTestSet.clear();
|
||||||
} else if (newTestStarts.exactMatch(line)) {
|
} else if (newTestStarts.exactMatch(line)) {
|
||||||
currentTestName = newTestStarts.cap(1);
|
currentTestName = newTestStarts.cap(1);
|
||||||
auto testResult = new TestResult(currentTestName);
|
auto testResult = new GTestResult(currentTestName);
|
||||||
testResult->setResult(Result::MessageTestCaseStart);
|
testResult->setResult(Result::MessageTestCaseStart);
|
||||||
testResult->setDescription(tr("Executing test case %1").arg(currentTestName));
|
testResult->setDescription(tr("Executing test case %1").arg(currentTestName));
|
||||||
testResultCreated(testResult);
|
testResultCreated(testResult);
|
||||||
} else if (newTestSetStarts.exactMatch(line)) {
|
} else if (newTestSetStarts.exactMatch(line)) {
|
||||||
currentTestSet = newTestSetStarts.cap(1);
|
currentTestSet = newTestSetStarts.cap(1);
|
||||||
auto testResult = new TestResult();
|
auto testResult = new GTestResult();
|
||||||
testResult->setResult(Result::MessageCurrentTest);
|
testResult->setResult(Result::MessageCurrentTest);
|
||||||
testResult->setDescription(tr("Entering test set %1").arg(currentTestSet));
|
testResult->setDescription(tr("Entering test set %1").arg(currentTestSet));
|
||||||
testResultCreated(testResult);
|
testResultCreated(testResult);
|
||||||
} else if (testSetSuccess.exactMatch(line)) {
|
} else if (testSetSuccess.exactMatch(line)) {
|
||||||
auto testResult = new TestResult(currentTestName);
|
auto testResult = new GTestResult(currentTestName);
|
||||||
testResult->setTestCase(currentTestSet);
|
testResult->setTestCase(currentTestSet);
|
||||||
testResult->setResult(Result::Pass);
|
testResult->setResult(Result::Pass);
|
||||||
testResultCreated(testResult);
|
testResultCreated(testResult);
|
||||||
testResult = new TestResult(currentTestName);
|
testResult = new GTestResult(currentTestName);
|
||||||
testResult->setTestCase(currentTestSet);
|
testResult->setTestCase(currentTestSet);
|
||||||
testResult->setResult(Result::MessageInternal);
|
testResult->setResult(Result::MessageInternal);
|
||||||
testResult->setDescription(tr("Execution took %1.").arg(testSetSuccess.cap(2)));
|
testResult->setDescription(tr("Execution took %1.").arg(testSetSuccess.cap(2)));
|
||||||
testResultCreated(testResult);
|
testResultCreated(testResult);
|
||||||
emit increaseProgress();
|
emit increaseProgress();
|
||||||
} else if (testSetFail.exactMatch(line)) {
|
} else if (testSetFail.exactMatch(line)) {
|
||||||
auto testResult = new TestResult(currentTestName);
|
auto testResult = new GTestResult(currentTestName);
|
||||||
testResult->setTestCase(currentTestSet);
|
testResult->setTestCase(currentTestSet);
|
||||||
testResult->setResult(Result::Fail);
|
testResult->setResult(Result::Fail);
|
||||||
description.chop(1);
|
description.chop(1);
|
||||||
@@ -402,7 +402,7 @@ void TestOutputReader::processGTestOutput()
|
|||||||
}
|
}
|
||||||
testResultCreated(testResult);
|
testResultCreated(testResult);
|
||||||
description.clear();
|
description.clear();
|
||||||
testResult = new TestResult(currentTestName);
|
testResult = new GTestResult(currentTestName);
|
||||||
testResult->setTestCase(currentTestSet);
|
testResult->setTestCase(currentTestSet);
|
||||||
testResult->setResult(Result::MessageInternal);
|
testResult->setResult(Result::MessageInternal);
|
||||||
testResult->setDescription(tr("Execution took %1.").arg(testSetFail.cap(2)));
|
testResult->setDescription(tr("Execution took %1.").arg(testSetFail.cap(2)));
|
||||||
|
@@ -37,6 +37,7 @@ TestResult::TestResult(const QString &className)
|
|||||||
: m_class(className)
|
: m_class(className)
|
||||||
, m_result(Result::Invalid)
|
, m_result(Result::Invalid)
|
||||||
, m_line(0)
|
, m_line(0)
|
||||||
|
, m_type(Qt)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,5 +147,16 @@ bool operator==(const TestResult &t1, const TestResult &t2)
|
|||||||
&& t1.result() == t2.result();
|
&& t1.result() == t2.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTestResult::QTestResult(const QString &className)
|
||||||
|
: TestResult(className)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GTestResult::GTestResult(const QString &className)
|
||||||
|
: TestResult(className)
|
||||||
|
{
|
||||||
|
setTestType(GTest);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Autotest
|
} // namespace Autotest
|
||||||
|
@@ -57,6 +57,12 @@ enum Type {
|
|||||||
class TestResult
|
class TestResult
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum TestType
|
||||||
|
{
|
||||||
|
Qt,
|
||||||
|
GTest
|
||||||
|
};
|
||||||
|
|
||||||
TestResult();
|
TestResult();
|
||||||
TestResult(const QString &className);
|
TestResult(const QString &className);
|
||||||
|
|
||||||
@@ -67,6 +73,7 @@ public:
|
|||||||
QString description() const { return m_description; }
|
QString description() const { return m_description; }
|
||||||
QString fileName() const { return m_file; }
|
QString fileName() const { return m_file; }
|
||||||
int line() const { return m_line; }
|
int line() const { return m_line; }
|
||||||
|
TestType type() const { return m_type; }
|
||||||
|
|
||||||
void setDescription(const QString &description) { m_description = description; }
|
void setDescription(const QString &description) { m_description = description; }
|
||||||
void setFileName(const QString &fileName) { m_file = fileName; }
|
void setFileName(const QString &fileName) { m_file = fileName; }
|
||||||
@@ -74,6 +81,7 @@ public:
|
|||||||
void setResult(Result::Type type) { m_result = type; }
|
void setResult(Result::Type type) { m_result = type; }
|
||||||
void setTestCase(const QString &testCase) { m_case = testCase; }
|
void setTestCase(const QString &testCase) { m_case = testCase; }
|
||||||
void setDataTag(const QString &dataTag) { m_dataTag = dataTag; }
|
void setDataTag(const QString &dataTag) { m_dataTag = dataTag; }
|
||||||
|
void setTestType(TestType type) { m_type = type; }
|
||||||
|
|
||||||
static Result::Type resultFromString(const QString &resultString);
|
static Result::Type resultFromString(const QString &resultString);
|
||||||
static Result::Type toResultType(int rt);
|
static Result::Type toResultType(int rt);
|
||||||
@@ -88,6 +96,7 @@ private:
|
|||||||
QString m_description;
|
QString m_description;
|
||||||
QString m_file;
|
QString m_file;
|
||||||
int m_line;
|
int m_line;
|
||||||
|
TestType m_type;
|
||||||
// environment?
|
// environment?
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -97,6 +106,18 @@ public:
|
|||||||
FaultyTestResult(Result::Type result, const QString &description);
|
FaultyTestResult(Result::Type result, const QString &description);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QTestResult : public TestResult
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QTestResult(const QString &className = QString());
|
||||||
|
};
|
||||||
|
|
||||||
|
class GTestResult : public TestResult
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GTestResult(const QString &className = QString());
|
||||||
|
};
|
||||||
|
|
||||||
bool operator==(const TestResult &t1, const TestResult &t2);
|
bool operator==(const TestResult &t1, const TestResult &t2);
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -48,7 +48,10 @@ QString TestResultDelegate::outputString(const TestResult &testResult, bool sele
|
|||||||
case Result::UnexpectedPass:
|
case Result::UnexpectedPass:
|
||||||
case Result::BlacklistedFail:
|
case Result::BlacklistedFail:
|
||||||
case Result::BlacklistedPass:
|
case Result::BlacklistedPass:
|
||||||
|
if (testResult.type() == TestResult::Qt)
|
||||||
output = testResult.className() + QLatin1String("::") + testResult.testCase();
|
output = testResult.className() + QLatin1String("::") + testResult.testCase();
|
||||||
|
else // TestResult::GTest
|
||||||
|
output = testResult.testCase();
|
||||||
if (!testResult.dataTag().isEmpty())
|
if (!testResult.dataTag().isEmpty())
|
||||||
output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag()));
|
output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag()));
|
||||||
if (selected && !desc.isEmpty()) {
|
if (selected && !desc.isEmpty()) {
|
||||||
|
Reference in New Issue
Block a user