开发者

NUnit GUI Runner and Apartment State

开发者 https://www.devze.com 2022-12-23 10:04 出处:网络
How do you set the apartment state in the NUnit GUI runner? I\'m trying to run a single NUnit test with WatiN and I\'m getting the message:

How do you set the apartment state in the NUnit GUI runner? I'm trying to run a single NUnit test with WatiN and I'm getting the message:

MyName开发者_高级运维space.LoginTests.CanLogin:

System.Threading.ThreadStateException : The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.


Starting with NUnit 2.5, use RequiresSTA attribute in your tests.


You need to add some configuration to your assembly's app.config file (if you don't have once, create a new one) to tell NUnit to run as 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>

(original source)

0

精彩评论

暂无评论...
验证码 换一张
取 消