Skip to content

Commit b5235a6

Browse files
authored
Fix EndOfClass cleanup for DataRow (#1020)
* Fix endOfClass cleanup for datarows * Use display name
1 parent 93d4a6e commit b5235a6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary<strin
133133
if (!this.IsTestMethodRunnable(testMethod, testMethodInfo, out var notRunnableResult))
134134
{
135135
bool shouldRunClassCleanup = false;
136-
this.classCleanupManager?.MarkTestComplete(testMethodInfo, out shouldRunClassCleanup);
136+
this.classCleanupManager?.MarkTestComplete(testMethodInfo, testMethod, out shouldRunClassCleanup);
137137
if (shouldRunClassCleanup)
138138
{
139139
testMethodInfo.Parent.RunClassCleanup(ClassCleanupBehavior.EndOfClass);
@@ -143,7 +143,7 @@ internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionary<strin
143143
}
144144

145145
var result = new TestMethodRunner(testMethodInfo, testMethod, testContext, MSTestSettings.CurrentSettings.CaptureDebugTraces, this.reflectHelper).Execute();
146-
this.RunClassCleanupIfEndOfClass(testMethodInfo, result);
146+
this.RunClassCleanupIfEndOfClass(testMethodInfo, testMethod, result);
147147
return result;
148148
}
149149
}
@@ -191,10 +191,10 @@ internal RunCleanupResult RunCleanup()
191191
return result;
192192
}
193193

194-
private void RunClassCleanupIfEndOfClass(TestMethodInfo testMethodInfo, UnitTestResult[] results)
194+
private void RunClassCleanupIfEndOfClass(TestMethodInfo testMethodInfo, TestMethod testMethod, UnitTestResult[] results)
195195
{
196196
bool shouldRunClassCleanup = false;
197-
this.classCleanupManager?.MarkTestComplete(testMethodInfo, out shouldRunClassCleanup);
197+
this.classCleanupManager?.MarkTestComplete(testMethodInfo, testMethod, out shouldRunClassCleanup);
198198
if (shouldRunClassCleanup)
199199
{
200200
string cleanupLogs = string.Empty;
@@ -356,16 +356,16 @@ public ClassCleanupManager(
356356
this.reflectHelper = reflectHelper ?? new ReflectHelper();
357357
}
358358

359-
public void MarkTestComplete(TestMethodInfo testMethod, out bool shouldCleanup)
359+
public void MarkTestComplete(TestMethodInfo testMethodInfo, TestMethod testMethod, out bool shouldCleanup)
360360
{
361361
shouldCleanup = false;
362-
var testsByClass = this.remainingTestsByClass[testMethod.TestClassName];
362+
var testsByClass = this.remainingTestsByClass[testMethodInfo.TestClassName];
363363
lock (testsByClass)
364364
{
365-
testsByClass.Remove(testMethod.TestMethodName);
366-
if (testsByClass.Count == 0 && testMethod.Parent.HasExecutableCleanupMethod)
365+
testsByClass.Remove(testMethod.DisplayName);
366+
if (testsByClass.Count == 0 && testMethodInfo.Parent.HasExecutableCleanupMethod)
367367
{
368-
var cleanupLifecycle = this.reflectHelper.GetClassCleanupBehavior(testMethod.Parent)
368+
var cleanupLifecycle = this.reflectHelper.GetClassCleanupBehavior(testMethodInfo.Parent)
369369
?? this.lifecycleFromMsTest
370370
?? this.lifecycleFromAssembly;
371371

0 commit comments

Comments
 (0)