forked from qt-creator/qt-creator
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:
@@ -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.
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
using namespace testing;
|
||||
|
||||
TEST(%{TestCaseName}, %{TestSetName})
|
||||
TEST(%{TestSuiteName}, %{TestCaseName})
|
||||
{
|
||||
EXPECT_EQ(1, 1);
|
||||
ASSERT_THAT(0, Eq(0));
|
||||
|
@@ -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",
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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<const GTestResult *>(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;
|
||||
|
@@ -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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user