How to run NUnit test in STA thread?

匆匆过客 提交于 2020-01-24 19:27:35

问题


We are in the process of porting a WPF app to .NET Core 3, preview 5. Some NUnit tests need to run in STA threads. How can this be done?

None of the attributes like [STAThread], [RequiresSTA], ... work. This also doesn't work: [assembly: RequiresThread(ApartmentState.STA)]

The Apparent namespace does not seem to be exposed in .NET Core 3.

Has anyone done this?


回答1:


ApartmentAttribute was first enabled for .NET Standard 2.0 in NUnit 3.12.

First update your version of the NUnit framework, then use [Apartment(ApartmentState.STA)].



来源:https://stackoverflow.com/questions/56567075/how-to-run-nunit-test-in-sta-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!