无法使用Nant运行nunit测试 [英] Cannot run nunit tests with Nant

查看:103
本文介绍了无法使用Nant运行nunit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用nant启动nunit ui测试并得到错误:

I'm trying to launch nunit ui tests with nant and get the error:

Buildfile:file:///c:/UItests/nant.build目标框架: 指定的Microsoft .NET Framework 4.0目标:构建

Buildfile: file:///c:/UItests/nant.build Target framework: Microsoft .NET Framework 4.0 Target(s) specified: build

内部版本:

[nunit2] 2012/06/20/13:29:52:设置方法异常: CurrentThread需要将其ApartmentState设置为Apar tmentState.STA能够自动执行Internet Explorer. [nunit2] 2012/06/20/13:29:52:设置方法中的异常:CurrentThread 需要将其ApartmentState设置为Apar tmentState.STA 能够自动执行Internet Explorer. [nunit2] 2012/06/20/13:29:52: 设置方法中的异常:CurrentThread需要具有它 ApartmentState设置为Apar tmentState.STA以能够自动化 IE浏览器. [nunit2] 2012/06/20/13:29:52:集合中的异常 up方法:CurrentThread需要将其ApartmentState设置为 Apar tmentState.STA能够自动执行Internet Explorer.
[nunit2] 2012/06/20/13:29:52:设置方法异常: CurrentThread需要将其ApartmentState设置为Apar tmentState.STA能够自动执行Internet Explorer.

[nunit2] 2012/06/20/13:29:52: Exception in set up method: The CurrentThread needs to have it's ApartmentState set to Apar tmentState.STA to be able to automate Internet Explorer. [nunit2] 2012/06/20/13:29:52: Exception in set up method: The CurrentThread needs to have it's ApartmentState set to Apar tmentState.STA to be able to automate Internet Explorer. [nunit2] 2012/06/20/13:29:52: Exception in set up method: The CurrentThread needs to have it's ApartmentState set to Apar tmentState.STA to be able to automate Internet Explorer. [nunit2] 2012/06/20/13:29:52: Exception in set up method: The CurrentThread needs to have it's ApartmentState set to Apar tmentState.STA to be able to automate Internet Explorer.
[nunit2] 2012/06/20/13:29:52: Exception in set up method: The CurrentThread needs to have it's ApartmentState set to Apar tmentState.STA to be able to automate Internet Explorer.

我尝试了项目随附的App.config,如下所示:

I tried with App.config that comes with my project, like this:

<test assemblyname="UITests.dll" appconfig="UITests.dll.config" />

我还手动创建了配置文件,并将其放入带有test和nunit程序集的文件夹中.但是没有任何帮助.在配置文件中,我有:

And also I created config file manually and put it to folder with test and nunit assemblies. But nothing helped. In config file I have:

 <add key="ApartmentState" value="STA" />

这是nant.build文件:

Here is nant.build file:

 <?xml version="1.0"?>
 <project name="UITests" default="build">
 <property name="build.dir" value="" />
 <target name="build">
  <nunit2>
<formatter type="Plain" />
<test assemblyname="${build.dir}UITests.dll" appconfig="UITests.dll.config" />
  </nunit2>
</target>
</project>

我错过了什么?

推荐答案

一种可能且简单的解决方案:

One possible and simple solution:

设置此:

[assembly: RequiresSTA]

在AssemblyInfo.cs文件中.

in AssemblyInfo.cs file.

这篇关于无法使用Nant运行nunit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆