How to run unit tests in STAThread mode?

后端 未结 4 634
醉话见心
醉话见心 2020-12-03 00:46

I would like to test an app that uses the Clipboard (WindowsForms) and I need the Clipboard in my unit tests also. In order to use it, it should run in STA mode, but since

4条回答
  •  余生分开走
    2020-12-03 01:03

    If you are using nunit 2.5+, you can use the new The RequiresSTAAttribute at class

    [TestFixture, RequiresSTA]
    

    or assembly level.

    [assembly:RequiresSTA]
    

    No need for config file. check: http://www.nunit.org/index.php?p=requiresSTA&r=2.5

提交回复
热议问题