我收到以下錯誤:設置單元狀態使用華廷與MSTest的
的CurrentThread需要有它的ApartmentState設置爲ApartmentState.STA能夠自動的Internet Explorer。
用下面的代碼:
[TestClass]
public class UnitTest1
{
[AssemblyInitialize]
public static void AssemblySetup(TestContext context)
{
}
[TestMethod]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\SomePath", "/")]
[UrlToTest("http://localhost/HomeView.aspx")]
public void TestMethod1()
{
using(IE ie = new IE("http://localhost/HomeView.aspx",true))
{
ie.TextField(Find.ById("MainContent_txtDLNumber")).TypeText("a235801945550");
}
}
}
是否有使用華廷與MSTest的一種不同的方法?
這是正確的。實際上,我使用的是需要與Nunit測試運行器相同的配置設置的resharper測試運行器。 – jparram 2010-12-29 17:31:07
@japrram:問題標籤應該更新爲列出nunit而不是mstest? – GregC 2011-04-28 05:36:54