diff --git a/src/plugins/autotest/gtest/gtesttreeitem.cpp b/src/plugins/autotest/gtest/gtesttreeitem.cpp index 3b2c680fe98..b0f11830383 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.cpp +++ b/src/plugins/autotest/gtest/gtesttreeitem.cpp @@ -295,7 +295,10 @@ QSet GTestTreeItem::internalTargets() const const auto cppMM = CppTools::CppModelManager::instance(); const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject()); const QString file = filePath(); - for (const CppTools::ProjectPart::Ptr projectPart : projectInfo.projectParts()) { + const QVector projectParts = projectInfo.projectParts(); + if (projectParts.isEmpty()) + return TestTreeItem::dependingInternalTargets(cppMM, file); + for (const CppTools::ProjectPart::Ptr projectPart : projectParts) { if (projectPart->projectFile == proFile() && Utils::anyOf(projectPart->files, [&file] (const CppTools::ProjectFile &pf) { return pf.path == file; diff --git a/src/plugins/autotest/testtreeitem.cpp b/src/plugins/autotest/testtreeitem.cpp index d27c689e5b0..05eab8439fd 100644 --- a/src/plugins/autotest/testtreeitem.cpp +++ b/src/plugins/autotest/testtreeitem.cpp @@ -288,6 +288,9 @@ QSet TestTreeItem::internalTargets() const { auto cppMM = CppTools::CppModelManager::instance(); const QList projectParts = cppMM->projectPart(m_filePath); + // if we have no project parts it's most likely a header with declarations only and CMake based + if (projectParts.isEmpty()) + return TestTreeItem::dependingInternalTargets(cppMM, m_filePath); QSet targets; for (const CppTools::ProjectPart::Ptr part : projectParts) { targets.insert(part->buildSystemTarget + '|' + part->projectFile);