Class Cleanup gets called immediately after a single test case using VSTestConsoleWrapper
See original GitHub issueDescribe 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?
Issue Analytics
- State:
- Created 6 months ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to run ClassCleanup (MSTest) after each class with ...
Each test class starts from ClassInitialize and finishes by ClassCleanup. My problem is that ClassCleanup isn't called at the end of each class, ......
Read more >Testing in Go: Clean Tests Using t.Cleanup - Ilija Eftimov
Cleanup registers a function to be called when the test and all its subtests complete. This means that even if our tests run...
Read more >Demystifying useEffect's clean-up function
useEffect's clean-up function can be pretty confusing, especially if you're still trying to think in lifecycle methods. Let's clarify the clean-up function ...
Read more >Understanding React's useEffect cleanup function
Learn React's useEffect cleanup function to prevent unwanted application behaviors like memory leaks by cleaning up effects.
Read more >The useEffect cleanup and the two circumstances it's called.
The cleanup function is a function returned from within the effect function. It gets called when the component unmounts but you probably ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
can we please add it as a feature to recognize duplicate test cases in a single run as individual test cases and run class cleanup only after all these test cases have finished running?
Thanks @agadekar,
in here the problem when happens when we run the same test twice from a class has only one test and that’s because in the code we check if all tests run then call the class cleanup which happens after first call to the test.