microsoft / testfx

MSTest framework and adapter
MIT License
679 stars 246 forks source link

ExecutionThreadAppartment.STA in runsettings doesn't work when tests are parallelized #3208

Open Evangelink opened 3 days ago

Evangelink commented 3 days ago

Describe the bug

When parallelizing the tests [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)], the fixtures or methods are not respecting STA configuration.

Analysis

The problem is coming from these lines: https://github.com/microsoft/testfx/blob/main/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs#L316-L348. Similarly to what is done in the rest of the code, we should have a logic to use custom thread when in STA and keep using threadpool for when we don't need STA.

AB#2114780