我正在探索由NUnit和Nant驱动的WatIN自动化框架。我在App.config中设置了Apartmentstate
<NUnit>
<TestRunner>
<!-- WatiN can only host IE in STA mode -->
<add key="ApartmentState" value="STA"/>
</TestRunner>
</NUnit>
我还在测试类中设置了[TestFixture,RequiresSTA]。当我使用nunit-console testrunner或Nunit GUI runner时,这非常适用。
在NAnt中使用Nunit2 runner会抛出此异常
[nunit2]:[DEBUG] CurrentThread需要将它的ApartmentState设置为ApartmentState.STA才能自动化Internet Explorer
如何解决此问题?
由于 积木
答案 0 :(得分:0)
我有类似的问题。当我从我的nant目标调用nunit-console.exe时,我能够通过添加/ nothread arg来修复它。
示例:
<exec verbose="true"
workingdir="${project::get-base-directory()}\build"
program="tools\nunit\nunit-console.exe" basedir="${project::get-base-directory()}">
<arg value="${ua-testproject.name}" />
<arg value="/nothread" />
<arg value="/xml:${ua-tests.report}" />
</exec>