我想测试一个使用剪贴板 (WindowsForms) 的应用程序,我的单元测试中也需要剪贴板。为了使用它,它应该在 STA 模式下运行,但是由于 NUnit TestFixture
没有 main 方法,我不知道在哪里/如何注释它。
最佳答案
如果你使用的是nunit 2.5+,你可以在类中使用新的RequiresSTAAttribute
[TestFixture, RequiresSTA]
或汇编级。
[assembly:RequiresSTA]
不需要配置文件。查看: http://www.nunit.org/index.php?p=requiresSTA&r=2.5
关于c# - 如何在 STAThread 模式下运行单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2434067/