PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

Fix over-discovery issue for unittest and pytest.

Open StellaHuang95 opened this issue 2 years ago • 1 comments

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-project

  • Unittest, folder view unittest-folder

  • Pytest, project view pytest - project

  • Pytest, folder view pytest - folder

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. no test available

StellaHuang95 avatar Jul 19 '22 20:07 StellaHuang95

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Jul 19 '22 20:07 sonarqubecloud[bot]