CC.Net 上的 Watin 测试失败 [英] Watin Tests fail on CC.Net

查看:25
本文介绍了CC.Net 上的 Watin 测试失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Windows Server 2003 下的 CC.Net 上使用 xUnit 运行 Watin 测试.

I'm running Watin tests with xUnit on CC.Net under Windows Server 2003.

我有很多测试,它们在带有 TestDriven.Net 的开发盒和带有 xUnit gui 应用程序的服务器上都运行良好.但是,当 CC.Net 运行测试(作为 MSBuild 任务的一部分)时,函数

I have lots of tests that all run fine on development boxes with TestDriven.Net and on the server with the xUnit gui app. However, when CC.Net runs the tests (as part of an MSBuild task) the function

ie.ContainsText("some text to find");

从不返回预期值.IE 对象上的其他函数和属性似乎工作正常:Button(...).Click()、TextBox(...).Value 等.

never returns the expected value. Other functions and properties on the IE object appear to work fine: Button(...).Click(), TextBox(...).Value, etc.

我知道服务帐户需要允许服务与桌面交互".

I am aware that the service account needs "Allow service to interact with the desktop".

我已经尝试在本地系统和本地管理员下运行此 CC 服务.管理员帐户只是挂起,似乎从未完成运行测试(尽管它确实创建了 iexplorer.exe 进程的实例.

I have tried this running CC service under Local System and local Administrator. The administrator account just hangs and never appears to finish running the tests (though it does create an instance of the iexplorer.exe process.

这是服务器权限的问题,还是我在配置中遗漏了什么?

Is this an issue with permissioning on the server, or have I left something out of the configuration?

推荐答案

我们刚刚弄清楚如何解决这个问题.我们现在有通过 CruiseControl.net 运行的 watin 测试作为服务运行.

We just finished figuring out how to work around this problem. We now have watin tests running through CruiseControl.net running as a service.

由于安全设置方式,我们需要我们的 cc.net 服务以特定用户身份运行,以便访问我们正在测试的网站.由于服务以域用户身份运行,因此在服务安全选项卡上禁用了允许用户与桌面交互"复选框.我们不想只从始终登录的用户运行命令进程,因为我们希望该进程在重新启动时自动启动.现在我们已经想通了

We need our cc.net service to run as a specific user in order to access the website we are testing due to the way the security is set up. Since the service is running as a domain user the 'Allow user to interact with desktop' checkbox is disabled on the service security tab. We don't want to just run the command process from an always logged in user because we want the process to start automatically on reboot. Now we have figured out

我们解决这个问题的方法是首先创建一个批处理文件来调用 nunit-console.exe.nunit-console.exe 的参数作为参数传递到批处理文件,然后传递参数.批处理文件的第二行也是最后一行返回从 nunit-console.exe 返回的返回代码.批处理文件基本上如下所示:

The way we worked around this was by first creating a batch file to call the nunit-console.exe. Parameters to nunit-console.exe are passed to the batch file as parameters which then passes the parameters on. The second, and last, line of the batch file returns the return code returned from nunit-console.exe. The batch file essentially looks like this:

 nunit-console.exe %1 %2
 exit /b %ERRORLEVEL%

传递给 nunit-console 的参数数量可能因您的需要而异.

The number of parameters you pass through to nunit-console may be different based on your needs.

我们在构建中使用了 nant,因此我们将现有的 nant 任务替换为调用 nunit-console 的 exec 任务,该任务调用 cmd.exe,如下所示:

We are using nant for our builds, so then we replaced our existing nant task to call nunit-console with an exec task that calls cmd.exe that looks like this:

   <exec program="cmd.exe" failonerror="true">
      <arg value="/interactive" />
      <arg value="/c" />
      <arg value="[batch file name]" />
      <arg value="[parameter one value]" />
      <arg value="[parameter two value" />
   </exec>

我不知道同样的任务在 msbuild 中会是什么样子,但我相信你可以查一下.最终的结果本质上是一个看起来像这样的命令:

I don't know what the same task would look like in msbuild but I'm sure you can look it up. The ultimate result is essentially a command that looks like this:

   cmd.exe /interactive /c [batch file name] [parameter one value] [parameter two value]

或者,您可以使用 nant 并创建 msbuld nant 任务来调用您现有的构建.

Alternatively, you could use nant and just create msbuld nant tasks to call your existing builds.

cmd.exe 的/interactive"参数是关键,它在有权与桌面交互的进程上运行批处理文件.如果需要 '/c' 参数,我实际上并不肯定,但它按原样工作.我们仍然告诉 nunit 将结果记录到同一个 xml 文件中,因此我们的合并任务不需要更改,并且将测试结果报告给巡航控制系统工作得很好.

The '/interactive' parameter to cmd.exe is the key, it runs the batch file on a process that has permission to interact with the desktop. I'm actually not positive if the '/c' parameter is required, but it is working as it is. We are still telling nunit to log the results to the same xml file so our merge task didn't need to change and the reporting of the test results to cruise control is working great.

这篇关于CC.Net 上的 Watin 测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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