Skip to content

Commit f83b676

Browse files
committed
Remove namespace from tests that are scheduled to run
1 parent 60bdcf2 commit f83b676

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

GoogleTestAdapter/Core/Model/TestCase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class TestCase
66
{
77
public string Source { get; }
88

9-
public string FullyQualifiedName { get; }
9+
public string FullyQualifiedName { get; set; }
1010
public string DisplayName { get; }
1111

1212
public string CodeFilePath { get; }

GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,8 @@ public void RunTests(IEnumerable<TestCase> testCasesToRun, string baseDir,
6363

6464
foreach (var testCase in groupedTestCases[executable])
6565
{
66-
string fullyQualifiedName = testCase.FullyQualifiedName;
66+
var key = Path.GetFullPath(testCase.Source) + ":" + testCase.FullyQualifiedName;
6767

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;
7768
ITestPropertySettings settings;
7869
// Tests with default settings are treated as not having settings and can be run together
7970
if (_settings.TestPropertySettingsContainer.TryGetSettings(key, out settings)

GoogleTestAdapter/TestAdapter/TestExecutor.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ private void DoRunTests(ICollection<TestCase> testCasesToRun, IRunContext runCon
229229

230230
_executor = new GoogleTestExecutor(_logger, _settings);
231231
}
232+
foreach (TestCase tc in testCasesToRun)
233+
{
234+
// If namespace exists then remove it so we can compare the test display names.
235+
// Using just tc.DisplayName does not work for paramaterized test cases.
236+
string fullyQualifiedName = tc.FullyQualifiedName;
237+
int frequency = fullyQualifiedName.Where(x => (x == '.')).Count();
238+
if (frequency > 1)
239+
{
240+
fullyQualifiedName = fullyQualifiedName.Substring(fullyQualifiedName.IndexOf('.') + 1);
241+
}
242+
243+
tc.FullyQualifiedName = fullyQualifiedName;
244+
}
245+
232246
_executor.RunTests(testCasesToRun, reporter, launcher,
233247
runContext.IsBeingDebugged, runContext.SolutionDirectory, processExecutor);
234248
reporter.AllTestsFinished();

0 commit comments

Comments
 (0)