I am getting the following exception when I try to run the SpecFlow test:
The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.
I have already added the following code in App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<!-- Valid values are STA,MTA. Others ignored. -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>
I am using VS 2010 and forcing my app to run as version 3.5.
I am also using the GUI display of nUnit tool!
If you have installed nunit 2.5+, use the new The RequiresSTAAttribute at class
TestFixture, RequiresSTA]
or assembly level. (at Assemblyinfo.cs)
using NUnit.Framework;
...
[assembly:RequiresSTA]
No need for config file. Check this link for more info: http://www.nunit.org/index.php?p=requiresSTA&r=2.5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With