PTVS
PTVS copied to clipboard
Fix over-discovery issue for unittest and pytest.
fixes https://github.com/microsoft/PTVS/issues/7043
The VS testing team has recently changed test discovery such that on machines with multiple CPU cores, it can discover tests from different sources
in parallel inside different test host processes. We have been over discovering tests because our adapter would unnecessarily (re)discover tests in all the .py files in each process. So for example, if we have 3 sources and 2 tests files, our adapter is going to return 3 * 2 tests discovered in total.
The fix is to just have our test discoverer get the list of all tests in the test root directory regardless, and then manually filter based on the test container/source.
I ran some tests for different scenarios and it's working as expected.
-
Unittest, project view
-
Unittest, folder view
-
Pytest, project view
-
Pytest, folder view
The only issue is that test explorer will throw an exception if no test is discovered and returned in certain test containers, but it is on the Test Explorer side.