[3.0 regression] Unable to run a test with timeout in STA ApartmentState
See original GitHub issueDescribe 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
Issue Analytics
- State:
- Created 6 months ago
- Reactions:1
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Problem with runnig NUnit tests under STA
This works fine if I run my unit test on NUnit console or on NUnit GUI without using a NUnit project file. However,...
Read more >Framework Release
For the NUnit3TestAdapter, you will need version 4.5 to run tests with NUnit 4. ... framework like setting the ApartmentState and enabling Timeout...
Read more >Timeouts:Issues and Resolutions
1. Idle Timeout. If the LambdaTest Selenium grid detects inactivity for 120 seconds then you may encounter the below error: · 2. Improper...
Read more >https://raw.githubusercontent.com/dotnet/samples/m...
Failing tests : build /p=IncludeTraits=ActiveIssue=17 20 area-System.Xml 2 XPath.XDocument tests fail because of lacking feature "XPath.
Read more >Visual studio performance testing quick reference guide pdf
show up properly 91 Socket errors or “Service Unavailable” errors when running a load test 92 Error “Failed to load results from the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cremor we have reverted the change and will include the fix in 3.0.3 (we hope to ship it next week).
@fforjan I believe this revert won’t be enough for you as you would want to run some tests with STA using .NET 6 and this won’t be possible (it was not possible in previous versions of MSTest). I have created #1674 to track providing a good solution for this use case.
Might be related to https://github.com/microsoft/vstest/issues/1865