vstest icon indicating copy to clipboard operation
vstest copied to clipboard

Class Cleanup gets called immediately after a single test case using VSTestConsoleWrapper

Open agadekar opened this issue 2 years ago • 6 comments

Describe the bug

I am using VsTestConsoleWrapper api to run tests. I have added same test method twice using below code -

Collection<TestCase> cases = new Collection<TestCase>();
  cases.Add(testCase);
  cases.Add(testCase);
var  consoleWrapper = new VsTestConsoleWrapper(runnerLocation, new ConsoleParameters { LogFilePath = logFilePath });
consoleWrapper.RunTests(cases, defaultRunSettings, handler);

However the ClassCleanup method gets called immediately after the first time test method is called and does not wait for the second instance to finish. Is this expected?

Expected behavior

class initialize  started at 3/9/2023 7:19:28 PM
test initialize  started at 3/9/2023 7:19:28 PM
TestA started at 3/9/2023 7:19:28 PM
TestA ended at 3/9/2023 7:20:18 PM
test cleanup  started at 3/9/2023 7:20:18 PM
class cleanup  started at 3/9/2023 **7:21:09** PM
test initialize  started at 3/9/2023 7:20:19 PM
TestA started at 3/9/2023 7:20:19 PM
TestA ended at 3/9/2023 7:21:09 PM
test cleanup  started at 3/9/2023 7:21:09 PM

Actual behavior

Logs from Test Run

test initialize  started at 3/9/2023 7:19:28 PM
TestA started at 3/9/2023 7:19:28 PM
TestA ended at 3/9/2023 7:20:18 PM
test cleanup  started at 3/9/2023 7:20:18 PM
class cleanup  started at 3/9/2023 7:20:19 PM
test initialize  started at 3/9/2023 7:20:19 PM
TestA started at 3/9/2023 7:20:19 PM
TestA ended at 3/9/2023 7:21:09 PM
test cleanup  started at 3/9/2023 7:21:09 PM

Additional context

Note how Class Cleanup was called at 7.20.19 before second run of TestA finished (7.21.09). Shouldn't it be called after 7.21.09?

agadekar avatar Mar 09 '23 20:03 agadekar