Skip to content

Commit 4937770

Browse files
committed
Change to removing Naemspace only for run execution now to preserve test case metadata for VS
1 parent 536be7a commit 4937770

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public void RunTests(IEnumerable<TestCase> testCasesToRun, string baseDir,
6464
foreach (var testCase in groupedTestCases[executable])
6565
{
6666
var key = Path.GetFullPath(testCase.Source) + ":" + testCase.FullyQualifiedName;
67-
6867
ITestPropertySettings settings;
6968
// Tests with default settings are treated as not having settings and can be run together
7069
if (_settings.TestPropertySettingsContainer.TryGetSettings(key, out settings)
@@ -181,6 +180,24 @@ public static void LogExecutionError(ILogger logger, string executable, string w
181180
private IEnumerable<TestResult> TryRunTests(string executable, string workingDir, IDictionary<string, string> envVars, bool isBeingDebugged,
182181
IDebuggedProcessLauncher debuggedLauncher, CommandLineGenerator.Args arguments, IProcessExecutor executor, StreamingStandardOutputTestResultParser streamingParser)
183182
{
183+
foreach (TestCase tc in arguments.TestCases)
184+
{
185+
// If namespace exists then remove it so we can compare the test display names.
186+
// Using just tc.DisplayName does not work for paramaterized test cases.
187+
string fullyQualifiedName = tc.FullyQualifiedName;
188+
int frequency = fullyQualifiedName.Where(x => (x == '.')).Count();
189+
if (frequency > 1)
190+
{
191+
string ns = fullyQualifiedName.Substring(0, fullyQualifiedName.IndexOf('.'));
192+
tc.Namespace = ns;
193+
_logger.LogInfo("NS removing: " + tc.Namespace);
194+
fullyQualifiedName = fullyQualifiedName.Substring(fullyQualifiedName.IndexOf('.') + 1);
195+
}
196+
197+
tc.FullyQualifiedName = fullyQualifiedName;
198+
_logger.LogInfo("Test Name after removing NS: " + tc.FullyQualifiedName);
199+
}
200+
184201
List<string> consoleOutput;
185202
if (_settings.UseNewTestExecutionFramework)
186203
{

GoogleTestAdapter/TestAdapter/TestExecutor.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -229,24 +229,6 @@ 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-
string ns = fullyQualifiedName.Substring(0, fullyQualifiedName.IndexOf('.'));
241-
tc.Namespace = ns;
242-
_logger.LogInfo("NS removing: " + tc.Namespace);
243-
fullyQualifiedName = fullyQualifiedName.Substring(fullyQualifiedName.IndexOf('.') + 1);
244-
}
245-
246-
tc.FullyQualifiedName = fullyQualifiedName;
247-
_logger.LogInfo("Test Name after removing NS: " + tc.FullyQualifiedName);
248-
}
249-
250232
_executor.RunTests(testCasesToRun, reporter, launcher,
251233
runContext.IsBeingDebugged, runContext.SolutionDirectory, processExecutor);
252234
reporter.AllTestsFinished();

0 commit comments

Comments
 (0)