AutoTest: Further adaption following official terms

GoogleTest started using the term Test Suite for grouping
related tests and Test Case for general tests.
This patch adapts the visual strings as well as some
internal API which used the same terms.
This completes 6189745a3b.

Change-Id: I0307c10b8b5f8574f31a68ee4320732f3e829532
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-05-24 07:17:50 +02:00
parent d8ab335e51
commit 5c6eb0a2ba
7 changed files with 38 additions and 45 deletions

View File

@@ -106,12 +106,12 @@
\li In the \uicontrol {Test framework} field, select \li In the \uicontrol {Test framework} field, select
\uicontrol {Google Test}. \uicontrol {Google Test}.
\li In the \uicontrol {Test suite name} field, enter a name for
the test suite.
\li In the \uicontrol {Test case name} field, enter a name for \li In the \uicontrol {Test case name} field, enter a name for
the test case. the test case.
\li In the \uicontrol {Test set name} field, enter a name for
the test set.
\li Select the \uicontrol {Enable C++ 11} check box to \li Select the \uicontrol {Enable C++ 11} check box to
support C++ 11 features in the test. support C++ 11 features in the test.

View File

@@ -11,7 +11,7 @@
using namespace testing; using namespace testing;
TEST(%{TestCaseName}, %{TestSetName}) TEST(%{TestSuiteName}, %{TestCaseName})
{ {
EXPECT_EQ(1, 1); EXPECT_EQ(1, 1);
ASSERT_THAT(0, Eq(0)); ASSERT_THAT(0, Eq(0));

View File

@@ -108,7 +108,7 @@
{ {
"name": "TestSuiteName", "name": "TestSuiteName",
"trDisplayName": "Test suite name:", "trDisplayName": "Test suite name:",
"visible": "%{JS: value('TestFrameWork') === 'BoostTest'}", "visible": "%{JS: ['BoostTest', 'GTest'].indexOf(value('TestFrameWork')) >= 0}",
"mandatory": true, "mandatory": true,
"type": "LineEdit", "type": "LineEdit",
"data": { "validator": "^[a-zA-Z_0-9]+$" } "data": { "validator": "^[a-zA-Z_0-9]+$" }
@@ -138,13 +138,6 @@
"checked": false "checked": false
} }
}, },
{
"name": "TestSetName",
"trDisplayName": "Test set name:",
"visible": "%{JS: value('TestFrameWork') === 'GTest'}",
"type": "LineEdit",
"data": { "validator": "^[a-zA-Z0-9]+$" }
},
{ {
"name": "GTestCXX11", "name": "GTestCXX11",
"trDisplayName": "Enable C++11", "trDisplayName": "Enable C++11",

View File

@@ -103,25 +103,25 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
testResult->setResult(ResultType::TestEnd); testResult->setResult(ResultType::TestEnd);
testResult->setDescription(tr("Test execution took %1").arg(testEnds.cap(2))); testResult->setDescription(tr("Test execution took %1").arg(testEnds.cap(2)));
reportResult(testResult); reportResult(testResult);
m_currentTestName.clear(); m_currentTestSuite.clear();
m_currentTestSet.clear(); m_currentTestCase.clear();
} else if (newTestStarts.exactMatch(line)) { } else if (newTestStarts.exactMatch(line)) {
setCurrentTestName(newTestStarts.cap(1)); setCurrentTestSuite(newTestStarts.cap(1));
TestResultPtr testResult = createDefaultResult(); TestResultPtr testResult = createDefaultResult();
testResult->setResult(ResultType::TestStart); testResult->setResult(ResultType::TestStart);
if (m_iteration > 1) { if (m_iteration > 1) {
testResult->setDescription(tr("Repeating test case %1 (iteration %2)") testResult->setDescription(tr("Repeating test suite %1 (iteration %2)")
.arg(m_currentTestName).arg(m_iteration)); .arg(m_currentTestSuite).arg(m_iteration));
} else { } else {
testResult->setDescription(tr("Executing test case %1").arg(m_currentTestName)); testResult->setDescription(tr("Executing test suite %1").arg(m_currentTestSuite));
} }
reportResult(testResult); reportResult(testResult);
} else if (newTestSetStarts.exactMatch(line)) { } else if (newTestSetStarts.exactMatch(line)) {
setCurrentTestSet(newTestSetStarts.cap(1)); setCurrentTestCase(newTestSetStarts.cap(1));
TestResultPtr testResult = TestResultPtr(new GTestResult(QString(), m_projectFile, TestResultPtr testResult = TestResultPtr(new GTestResult(QString(), m_projectFile,
QString())); QString()));
testResult->setResult(ResultType::MessageCurrentTest); testResult->setResult(ResultType::MessageCurrentTest);
testResult->setDescription(tr("Entering test set %1").arg(m_currentTestSet)); testResult->setDescription(tr("Entering test case %1").arg(m_currentTestCase));
reportResult(testResult); reportResult(testResult);
m_description.clear(); m_description.clear();
} else if (testSetSuccess.exactMatch(line)) { } else if (testSetSuccess.exactMatch(line)) {
@@ -176,8 +176,8 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
TestResultPtr GTestOutputReader::createDefaultResult() const TestResultPtr GTestOutputReader::createDefaultResult() const
{ {
GTestResult *result = new GTestResult(id(), m_projectFile, m_currentTestName); GTestResult *result = new GTestResult(id(), m_projectFile, m_currentTestSuite);
result->setTestSetName(m_currentTestSet); result->setTestCaseName(m_currentTestCase);
result->setIteration(m_iteration); result->setIteration(m_iteration);
const TestTreeItem *testItem = result->findTestTreeItem(); const TestTreeItem *testItem = result->findTestTreeItem();
@@ -190,14 +190,14 @@ TestResultPtr GTestOutputReader::createDefaultResult() const
return TestResultPtr(result); return TestResultPtr(result);
} }
void GTestOutputReader::setCurrentTestSet(const QString &testSet) void GTestOutputReader::setCurrentTestCase(const QString &testCase)
{ {
m_currentTestSet = testSet; m_currentTestCase = testCase;
} }
void GTestOutputReader::setCurrentTestName(const QString &testName) void GTestOutputReader::setCurrentTestSuite(const QString &testSuite)
{ {
m_currentTestName = testName; m_currentTestSuite = testSuite;
} }
} // namespace Internal } // namespace Internal

View File

@@ -48,12 +48,12 @@ protected:
TestResultPtr createDefaultResult() const override; TestResultPtr createDefaultResult() const override;
private: private:
void setCurrentTestSet(const QString &testSet); void setCurrentTestCase(const QString &testCase);
void setCurrentTestName(const QString &testName); void setCurrentTestSuite(const QString &testSuite);
QString m_projectFile; QString m_projectFile;
QString m_currentTestName; QString m_currentTestSuite;
QString m_currentTestSet; QString m_currentTestCase;
QString m_description; QString m_description;
int m_iteration = 1; int m_iteration = 1;
}; };

View File

@@ -46,7 +46,7 @@ const QString GTestResult::outputString(bool selected) const
switch (result()) { switch (result()) {
case ResultType::Pass: case ResultType::Pass:
case ResultType::Fail: case ResultType::Fail:
output = m_testSetName; output = m_testCaseName;
if (selected && !desc.isEmpty()) if (selected && !desc.isEmpty())
output.append('\n').append(desc); output.append('\n').append(desc);
break; break;
@@ -64,14 +64,14 @@ bool GTestResult::isDirectParentOf(const TestResult *other, bool *needsIntermedi
return false; return false;
const GTestResult *gtOther = static_cast<const GTestResult *>(other); const GTestResult *gtOther = static_cast<const GTestResult *>(other);
if (m_testSetName == gtOther->m_testSetName) { if (m_testCaseName == gtOther->m_testCaseName) {
const ResultType otherResult = other->result(); const ResultType otherResult = other->result();
if (otherResult == ResultType::MessageInternal || otherResult == ResultType::MessageLocation) if (otherResult == ResultType::MessageInternal || otherResult == ResultType::MessageLocation)
return result() != ResultType::MessageInternal && result() != ResultType::MessageLocation; return result() != ResultType::MessageInternal && result() != ResultType::MessageLocation;
} }
if (m_iteration != gtOther->m_iteration) if (m_iteration != gtOther->m_iteration)
return false; return false;
return isTest() && gtOther->isTestSet(); return isTestSuite() && gtOther->isTestCase();
} }
static QString normalizeName(const QString &name) static QString normalizeName(const QString &name)
@@ -110,22 +110,22 @@ bool GTestResult::matches(const TestTreeItem *treeItem) const
if (treeItem->proFile() != m_projectFile) if (treeItem->proFile() != m_projectFile)
return false; return false;
if (isTest()) if (isTestSuite())
return matchesTestCase(treeItem); return matchesTestSuite(treeItem);
return matchesTestFunctionOrSet(treeItem); return matchesTestCase(treeItem);
} }
bool GTestResult::matchesTestFunctionOrSet(const TestTreeItem *treeItem) const bool GTestResult::matchesTestCase(const TestTreeItem *treeItem) const
{ {
if (treeItem->type() != TestTreeItem::TestCase) if (treeItem->type() != TestTreeItem::TestCase)
return false; return false;
const QString testItemTestSet = treeItem->parentItem()->name() + '.' + treeItem->name(); const QString testItemTestCase = treeItem->parentItem()->name() + '.' + treeItem->name();
return testItemTestSet == normalizeName(m_testSetName); return testItemTestCase == normalizeName(m_testCaseName);
} }
bool GTestResult::matchesTestCase(const TestTreeItem *treeItem) const bool GTestResult::matchesTestSuite(const TestTreeItem *treeItem) const
{ {
if (treeItem->type() != TestTreeItem::TestSuite) if (treeItem->type() != TestTreeItem::TestSuite)
return false; return false;

View File

@@ -36,20 +36,20 @@ public:
GTestResult(const QString &id, const QString &projectFile, const QString &name); GTestResult(const QString &id, const QString &projectFile, const QString &name);
const QString outputString(bool selected) const override; const QString outputString(bool selected) const override;
void setTestSetName(const QString &testSetName) { m_testSetName = testSetName; } void setTestCaseName(const QString &testSetName) { m_testCaseName = testSetName; }
void setIteration(int iteration) { m_iteration = iteration; } void setIteration(int iteration) { m_iteration = iteration; }
bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const override; bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const override;
virtual const TestTreeItem *findTestTreeItem() const override; virtual const TestTreeItem *findTestTreeItem() const override;
private: private:
bool isTest() const { return m_testSetName.isEmpty(); } bool isTestSuite() const { return m_testCaseName.isEmpty(); }
bool isTestSet() const { return !m_testSetName.isEmpty(); } bool isTestCase() const { return !m_testCaseName.isEmpty(); }
bool matches(const TestTreeItem *item) const; bool matches(const TestTreeItem *item) const;
bool matchesTestFunctionOrSet(const TestTreeItem *treeItem) const;
bool matchesTestCase(const TestTreeItem *treeItem) const; bool matchesTestCase(const TestTreeItem *treeItem) const;
bool matchesTestSuite(const TestTreeItem *treeItem) const;
QString m_testSetName; QString m_testCaseName;
QString m_projectFile; QString m_projectFile;
int m_iteration = 1; int m_iteration = 1;
}; };