Skip to content

Commit 5cffdb9

Browse files
committed
Reverting back to FQN and and removing namespace from FindTestCase() if exists.
Previously using tc.DisplayName causes a regression where paramaterized tests were not run. Therefore, we are switching back to FQN, but removing the namespace if it exists in the test case FQN, otherwise the names will not match since the console output name does not include namespaces.
1 parent 7855799 commit 5cffdb9

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ 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.DisplayName;
66+
var key = Path.GetFullPath(testCase.Source) + ":" + testCase.FullyQualifiedName;
6767
ITestPropertySettings settings;
6868
// Tests with default settings are treated as not having settings and can be run together
6969
if (_settings.TestPropertySettingsContainer.TryGetSettings(key, out settings)

GoogleTestAdapter/Core/TestResults/StandardOutputTestResultParser.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ private TestResult CreateTestResult(int indexOfTestcase)
5959
int currentLineIndex = indexOfTestcase;
6060

6161
string line = _consoleOutput[currentLineIndex++];
62-
string testDisplayName = RemovePrefix(line).Trim();
63-
TestCase testCase = FindTestcase(testDisplayName);
62+
string qualifiedTestname = RemovePrefix(line).Trim();
63+
TestCase testCase = FindTestcase(qualifiedTestname);
6464
if (testCase == null)
6565
{
6666
_logger.DebugWarning(String.Format(Resources.NoKnownTestCaseMessage, line));
@@ -189,14 +189,31 @@ private int FindIndexOfNextTestcase(int currentIndex)
189189
return -1;
190190
}
191191

192-
private TestCase FindTestcase(string testDisplayName)
192+
private TestCase FindTestcase(string qualifiedTestname)
193193
{
194-
return FindTestcase(testDisplayName, _testCasesRun);
194+
return FindTestcase(qualifiedTestname, _testCasesRun);
195195
}
196196

197-
public static TestCase FindTestcase(string testDisplayName, IList<TestCase> testCasesRun)
197+
public static TestCase FindTestcase(string qualifiedTestname, IList<TestCase> testCasesRun)
198198
{
199-
return testCasesRun.SingleOrDefault(tc => tc.DisplayName == testDisplayName);
199+
foreach (TestCase tc in testCasesRun)
200+
{
201+
// If namespace exists then remove it so we can compare the test display names.
202+
// Using just tc.DisplayName does not work for paramaterized test cases.
203+
string fullyQualifiedName = tc.FullyQualifiedName;
204+
int frequency = fullyQualifiedName.Where(x => (x == '.')).Count();
205+
if (frequency > 1)
206+
{
207+
fullyQualifiedName = fullyQualifiedName.Substring(fullyQualifiedName.IndexOf('.') + 1);
208+
}
209+
210+
if (fullyQualifiedName == qualifiedTestname)
211+
{
212+
return tc;
213+
}
214+
}
215+
216+
return null;
200217
}
201218

202219
public static bool IsRunLine(string line)

0 commit comments

Comments
 (0)