[英]NUnit GUI Runner and Apartment State
如何在NUnit GUI運行器中設置單元狀態? 我正在嘗試使用WatiN運行單個NUnit測試,我收到消息:
MyNamespace.LoginTests.CanLogin:
System.Threading.ThreadStateException:CurrentThread需要將它的ApartmentState設置為ApartmentState.STA才能自動化Internet Explorer。
從NUnit 2.5開始,在測試中使用RequiresSTA屬性。
您需要在程序集的app.config文件中添加一些配置(如果您沒有,請創建一個新的)以告訴NUnit以STA身份運行:
<?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>
( 原始來源 )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.