VSTest (not MSTest) WaitHandler.WaitAll STA Thread error

438 views Asked by At

I am trying it in VS2017. I am writing a test using VSTest framework. Method, for which I am writing this test uses multi threads. While executing test I get STA error. I looked internet and found many suggestions to fix it in runsettings. I already have existing runsettings, I tried to add below entries, nothing seems worked, and still STA error while running the test

For below setting, no Invalid Setting error but STA thread issue remains

<RunSettings>      
<!-- ... -->
<TestSettings>
    <Execution>
        <!-- ... -->
    <ExecutionThread apartmentState="MTA" />
</Execution>
</TestSettings>

Invalid settings 'RunConfiguration' for below changes

<RunSettings>
<RunConfiguration>
<!-- -->
<ExecutionThread apartmentState="MTA" />
</RunConfiguration>
</RunSettings>

As per this: https://github.com/Microsoft/vstest-docs/blob/master/docs/configure.md I am changing as below:

<RunSettings>
<RunConfiguration>
<!-- -->
<ExecutionThreadApartmentState>MTA</ExecutionThreadApartmentState>
</RunConfiguration>
</RunSettings>

But I am still getting error for Invalid settings 'RunConfiguration'. Please suggest.

1

There are 1 answers

0
Satya Madala On

As per above link ExecutionThreadApartmentState in runsettings supported from VS 2017 update 5. For earlier versions you can set in file C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.executionengine.exe.config. Refer: https://github.com/Microsoft/vstest-docs/blob/master/docs/configure.md#execution-thread-apartment-state