From 5c6eb0a2bac1cf644cbccf200fc547668e0079ca Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 24 May 2019 07:17:50 +0200 Subject: [PATCH] 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 6189745a3b8d3a24627193f9ad8fb18fa84099ed. Change-Id: I0307c10b8b5f8574f31a68ee4320732f3e829532 Reviewed-by: David Schulz --- .../howto/creator-only/creator-autotest.qdoc | 6 ++-- .../wizards/autotest/files/tst_src.h | 2 +- .../templates/wizards/autotest/wizard.json | 9 +----- .../autotest/gtest/gtestoutputreader.cpp | 28 +++++++++---------- .../autotest/gtest/gtestoutputreader.h | 8 +++--- src/plugins/autotest/gtest/gtestresult.cpp | 20 ++++++------- src/plugins/autotest/gtest/gtestresult.h | 10 +++---- 7 files changed, 38 insertions(+), 45 deletions(-) diff --git a/doc/src/howto/creator-only/creator-autotest.qdoc b/doc/src/howto/creator-only/creator-autotest.qdoc index d5ece2aca0d..4c0205eaa1f 100644 --- a/doc/src/howto/creator-only/creator-autotest.qdoc +++ b/doc/src/howto/creator-only/creator-autotest.qdoc @@ -106,12 +106,12 @@ \li In the \uicontrol {Test framework} field, select \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 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 support C++ 11 features in the test. diff --git a/share/qtcreator/templates/wizards/autotest/files/tst_src.h b/share/qtcreator/templates/wizards/autotest/files/tst_src.h index 9e6c619c5f1..ef29240cd5e 100644 --- a/share/qtcreator/templates/wizards/autotest/files/tst_src.h +++ b/share/qtcreator/templates/wizards/autotest/files/tst_src.h @@ -11,7 +11,7 @@ using namespace testing; -TEST(%{TestCaseName}, %{TestSetName}) +TEST(%{TestSuiteName}, %{TestCaseName}) { EXPECT_EQ(1, 1); ASSERT_THAT(0, Eq(0)); diff --git a/share/qtcreator/templates/wizards/autotest/wizard.json b/share/qtcreator/templates/wizards/autotest/wizard.json index efaa6b36a0b..83a4be09a4f 100644 --- a/share/qtcreator/templates/wizards/autotest/wizard.json +++ b/share/qtcreator/templates/wizards/autotest/wizard.json @@ -108,7 +108,7 @@ { "name": "TestSuiteName", "trDisplayName": "Test suite name:", - "visible": "%{JS: value('TestFrameWork') === 'BoostTest'}", + "visible": "%{JS: ['BoostTest', 'GTest'].indexOf(value('TestFrameWork')) >= 0}", "mandatory": true, "type": "LineEdit", "data": { "validator": "^[a-zA-Z_0-9]+$" } @@ -138,13 +138,6 @@ "checked": false } }, - { - "name": "TestSetName", - "trDisplayName": "Test set name:", - "visible": "%{JS: value('TestFrameWork') === 'GTest'}", - "type": "LineEdit", - "data": { "validator": "^[a-zA-Z0-9]+$" } - }, { "name": "GTestCXX11", "trDisplayName": "Enable C++11", diff --git a/src/plugins/autotest/gtest/gtestoutputreader.cpp b/src/plugins/autotest/gtest/gtestoutputreader.cpp index a6da61716fa..e1cdf085a4a 100644 --- a/src/plugins/autotest/gtest/gtestoutputreader.cpp +++ b/src/plugins/autotest/gtest/gtestoutputreader.cpp @@ -103,25 +103,25 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin testResult->setResult(ResultType::TestEnd); testResult->setDescription(tr("Test execution took %1").arg(testEnds.cap(2))); reportResult(testResult); - m_currentTestName.clear(); - m_currentTestSet.clear(); + m_currentTestSuite.clear(); + m_currentTestCase.clear(); } else if (newTestStarts.exactMatch(line)) { - setCurrentTestName(newTestStarts.cap(1)); + setCurrentTestSuite(newTestStarts.cap(1)); TestResultPtr testResult = createDefaultResult(); testResult->setResult(ResultType::TestStart); if (m_iteration > 1) { - testResult->setDescription(tr("Repeating test case %1 (iteration %2)") - .arg(m_currentTestName).arg(m_iteration)); + testResult->setDescription(tr("Repeating test suite %1 (iteration %2)") + .arg(m_currentTestSuite).arg(m_iteration)); } else { - testResult->setDescription(tr("Executing test case %1").arg(m_currentTestName)); + testResult->setDescription(tr("Executing test suite %1").arg(m_currentTestSuite)); } reportResult(testResult); } else if (newTestSetStarts.exactMatch(line)) { - setCurrentTestSet(newTestSetStarts.cap(1)); + setCurrentTestCase(newTestSetStarts.cap(1)); TestResultPtr testResult = TestResultPtr(new GTestResult(QString(), m_projectFile, QString())); 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); m_description.clear(); } else if (testSetSuccess.exactMatch(line)) { @@ -176,8 +176,8 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin TestResultPtr GTestOutputReader::createDefaultResult() const { - GTestResult *result = new GTestResult(id(), m_projectFile, m_currentTestName); - result->setTestSetName(m_currentTestSet); + GTestResult *result = new GTestResult(id(), m_projectFile, m_currentTestSuite); + result->setTestCaseName(m_currentTestCase); result->setIteration(m_iteration); const TestTreeItem *testItem = result->findTestTreeItem(); @@ -190,14 +190,14 @@ TestResultPtr GTestOutputReader::createDefaultResult() const 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 diff --git a/src/plugins/autotest/gtest/gtestoutputreader.h b/src/plugins/autotest/gtest/gtestoutputreader.h index 8f29ae73e17..6684b77f44e 100644 --- a/src/plugins/autotest/gtest/gtestoutputreader.h +++ b/src/plugins/autotest/gtest/gtestoutputreader.h @@ -48,12 +48,12 @@ protected: TestResultPtr createDefaultResult() const override; private: - void setCurrentTestSet(const QString &testSet); - void setCurrentTestName(const QString &testName); + void setCurrentTestCase(const QString &testCase); + void setCurrentTestSuite(const QString &testSuite); QString m_projectFile; - QString m_currentTestName; - QString m_currentTestSet; + QString m_currentTestSuite; + QString m_currentTestCase; QString m_description; int m_iteration = 1; }; diff --git a/src/plugins/autotest/gtest/gtestresult.cpp b/src/plugins/autotest/gtest/gtestresult.cpp index b943c8d1410..8893bd363a7 100644 --- a/src/plugins/autotest/gtest/gtestresult.cpp +++ b/src/plugins/autotest/gtest/gtestresult.cpp @@ -46,7 +46,7 @@ const QString GTestResult::outputString(bool selected) const switch (result()) { case ResultType::Pass: case ResultType::Fail: - output = m_testSetName; + output = m_testCaseName; if (selected && !desc.isEmpty()) output.append('\n').append(desc); break; @@ -64,14 +64,14 @@ bool GTestResult::isDirectParentOf(const TestResult *other, bool *needsIntermedi return false; const GTestResult *gtOther = static_cast(other); - if (m_testSetName == gtOther->m_testSetName) { + if (m_testCaseName == gtOther->m_testCaseName) { const ResultType otherResult = other->result(); if (otherResult == ResultType::MessageInternal || otherResult == ResultType::MessageLocation) return result() != ResultType::MessageInternal && result() != ResultType::MessageLocation; } if (m_iteration != gtOther->m_iteration) return false; - return isTest() && gtOther->isTestSet(); + return isTestSuite() && gtOther->isTestCase(); } static QString normalizeName(const QString &name) @@ -110,22 +110,22 @@ bool GTestResult::matches(const TestTreeItem *treeItem) const if (treeItem->proFile() != m_projectFile) return false; - if (isTest()) - return matchesTestCase(treeItem); + if (isTestSuite()) + 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) return false; - const QString testItemTestSet = treeItem->parentItem()->name() + '.' + treeItem->name(); - return testItemTestSet == normalizeName(m_testSetName); + const QString testItemTestCase = treeItem->parentItem()->name() + '.' + treeItem->name(); + return testItemTestCase == normalizeName(m_testCaseName); } -bool GTestResult::matchesTestCase(const TestTreeItem *treeItem) const +bool GTestResult::matchesTestSuite(const TestTreeItem *treeItem) const { if (treeItem->type() != TestTreeItem::TestSuite) return false; diff --git a/src/plugins/autotest/gtest/gtestresult.h b/src/plugins/autotest/gtest/gtestresult.h index 20623fdf5d8..a7922133278 100644 --- a/src/plugins/autotest/gtest/gtestresult.h +++ b/src/plugins/autotest/gtest/gtestresult.h @@ -36,20 +36,20 @@ public: GTestResult(const QString &id, const QString &projectFile, const QString &name); 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; } bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const override; virtual const TestTreeItem *findTestTreeItem() const override; private: - bool isTest() const { return m_testSetName.isEmpty(); } - bool isTestSet() const { return !m_testSetName.isEmpty(); } + bool isTestSuite() const { return m_testCaseName.isEmpty(); } + bool isTestCase() const { return !m_testCaseName.isEmpty(); } bool matches(const TestTreeItem *item) const; - bool matchesTestFunctionOrSet(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; int m_iteration = 1; };