當我嘗試運行華廷測試槽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?