aza*_*arp 5 nunit watin unit-testing
当我尝试运行SpecFlow测试时,我收到以下异常:
CurrentThread需要将它的ApartmentState设置为ApartmentState.STA才能自动化Internet Explorer.
我已经在App.config中添加了以下代码:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<!-- Valid values are STA,MTA. Others ignored. -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我正在使用VS 2010并强制我的应用程序以3.5版本运行.
我也在使用nUnit工具的GUI显示!
mas*_*2k1 12
如果您已经安装了nunit 2.5+,请在课堂上使用新的RequiresSTAAttribute
TestFixture,RequiresSTA]
或装配水平.(在Assemblyinfo.cs)
使用NUnit.Framework;
...
[组件:RequiresSTA]
不需要配置文件.查看此链接以获取更多信息:http://www.nunit.org/index.php? p = requiresSTA& r = 2.5
下面的代码
不见了。
无论如何,当我使用 WatiN + Nunit + MSVS 时,我在测试项目中有这样的配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<!-- Valid values are STA,MTA. Others ignored. -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>
Run Code Online (Sandbox Code Playgroud)