forked from qt-creator/qt-creator
AutoTest: Add action to run all tests from current file
Run specific test functions since one test case can be implemented in multiple files. Task-number: QTCREATORBUG-20329 Change-Id: I07f435c264f18e9608caa5b7ee20dff2d33ee9c0 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
committed by
Christian Stenger
parent
887a0538cd
commit
57edd22d11
@@ -279,6 +279,36 @@ QList<TestConfiguration *> QuickTestTreeItem::getSelectedTestConfigurations() co
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<TestConfiguration *> QuickTestTreeItem::getTestConfigurationsForFile(const Utils::FileName &fileName) const
|
||||
{
|
||||
QList<TestConfiguration *> result;
|
||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
|
||||
if (!project || type() != Root)
|
||||
return result;
|
||||
|
||||
QHash<TestTreeItem *, QStringList> testFunctions;
|
||||
const QString &file = fileName.toString();
|
||||
forAllChildren([&testFunctions, &file](TestTreeItem *node) {
|
||||
if (node->type() == Type::TestFunctionOrSet && node->filePath() == file) {
|
||||
QTC_ASSERT(node->parentItem(), return);
|
||||
TestTreeItem *testCase = node->parentItem();
|
||||
QTC_ASSERT(testCase->type() == Type::TestCase, return);
|
||||
if (testCase->name().isEmpty())
|
||||
return;
|
||||
testFunctions[testCase] << testCase->name() + "::" + node->name();
|
||||
}
|
||||
});
|
||||
|
||||
for (auto it = testFunctions.cbegin(), end = testFunctions.cend(); it != end; ++it) {
|
||||
TestConfiguration *tc = it.key()->testConfiguration();
|
||||
QTC_ASSERT(tc, continue);
|
||||
tc->setTestCases(it.value());
|
||||
result << tc;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
|
||||
{
|
||||
QTC_ASSERT(result, return nullptr);
|
||||
|
||||
Reference in New Issue
Block a user