当我尝试运行华廷测试槽NUnit的IDE中,我得到错误信息:使用Nunit错误运行WatiN测试?
ConsoleApplication1.Tests.CanBrowseToMicrosoft: System.Threading.ThreadStateException:本CurrentThread需要有它的ApartmentState设置为ApartmentState.STA能够自动化Internet Explorer。
我创建了一个名为ConsoleApplication1.exe.config应用程序配置文件,该文件是如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>
我班Tests.cs低于:
[TestFixture]
public class Tests
{
[Test]
public void CanBrowseToMicrosoft()
{
using (var browser = new IE())
{
browser.GoTo("http://www.microsoft.com/");
Assert.That("Microsoft Corporation", Is.EqualTo(browser.Title));
}
}
}
难道我做错了什么?
我遇到的另一个问题是,如何让NUnit测试结果显示在vs2008 ide中,而不必运行NUnit Gui?