Describe the bug
MSTest v2 ran all tests in STA ApartmentState when executed in a .NET Framework runtime. v3 runs "normal" tests still in STA, but tests that have a TimeoutAttribute applied now run in MTA.
Steps To Reproduce
Run these tests with various versions of MSTest and runtimes:
[TestMethod]
public void TestMethod1()
{
// Outputs:
// MSTest net7.0 net48
// 2.2.10 MTA STA
// 3.0.2 MTA STA
Console.WriteLine(Thread.CurrentThread.GetApartmentState());
}
[TestMethod, Timeout(1000)]
public void TestMethod2()
{
// Outputs:
// MSTest net7.0 net48
// 2.2.10 MTA STA
// 3.0.2 MTA MTA <-- Problem
Console.WriteLine(Thread.CurrentThread.GetApartmentState());
}
Expected behavior
Either MSTest v2 behavior should be retained, or I should have a way to force STA on an unit test.
Actual behavior
Tests with timeout always run in MTA.
Additional context
I need STA to run UI (WPF) tests. Those tests try to execute WPF commands which now fail with InvalidOperationException: The calling thread must be STA, because many UI components require this.
This is most likely a side effect of #1296
The package "MSTest.STAExtensions" which is mentioned in #21 does not help/work, see saikrishnav/testfxSTAext#5
Related: #320
AB#1822144
Describe the bug
MSTest v2 ran all tests in STA ApartmentState when executed in a .NET Framework runtime. v3 runs "normal" tests still in STA, but tests that have a
TimeoutAttributeapplied now run in MTA.Steps To Reproduce
Run these tests with various versions of MSTest and runtimes:
Expected behavior
Either MSTest v2 behavior should be retained, or I should have a way to force STA on an unit test.
Actual behavior
Tests with timeout always run in MTA.
Additional context
I need STA to run UI (WPF) tests. Those tests try to execute WPF commands which now fail with
InvalidOperationException: The calling thread must be STA, because many UI components require this.This is most likely a side effect of #1296
The package "MSTest.STAExtensions" which is mentioned in #21 does not help/work, see saikrishnav/testfxSTAext#5
Related: #320
AB#1822144