Skip to content

Commit 60bdcf2

Browse files
committed
Remove namespace when passing tests to gtest
Previously passing the entire fully qualified name caused a regression where gtest could not run individual tests that are contianed within a namespace, because gtest has no knowledge of namespaces.
1 parent a134e27 commit 60bdcf2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,17 @@ public void RunTests(IEnumerable<TestCase> testCasesToRun, string baseDir,
6363

6464
foreach (var testCase in groupedTestCases[executable])
6565
{
66-
var key = Path.GetFullPath(testCase.Source) + ":" + testCase.FullyQualifiedName;
66+
string fullyQualifiedName = testCase.FullyQualifiedName;
67+
68+
// If testCase contains a namespace then remove it because GoogleTest has no knowledge of namespaces.
69+
int frequency = fullyQualifiedName.Where(x => (x == '.')).Count();
70+
71+
if (frequency > 1)
72+
{
73+
fullyQualifiedName = fullyQualifiedName.Substring(fullyQualifiedName.IndexOf('.') + 1);
74+
}
75+
76+
var key = Path.GetFullPath(testCase.Source) + ":" + fullyQualifiedName;
6777
ITestPropertySettings settings;
6878
// Tests with default settings are treated as not having settings and can be run together
6979
if (_settings.TestPropertySettingsContainer.TryGetSettings(key, out settings)

0 commit comments

Comments
 (0)