如何配置TestStack.White超时? [英] How can I configure TestStack.White timeouts?

查看:144
本文介绍了如何配置TestStack.White超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2010,并且通过NuGet获得了TestStack.White(我获得了版本0.10.3.118).

I'm using Visual Studio 2010 and I got TestStack.White via NuGet (I got version 0.10.3.118).

问题是,我的测试单击了一个按钮,该按钮触发的动作超过了默认的5秒超时.所以我的测试总是会产生:

Problem is, my test clicks a button which triggers an action that exceeds the default 5 second timeout. So my test always yields:

[Error] 'White.Core.Interceptors.CoreInterceptor' Error when invoking Click, on Button with parameters: 

White.Core.UIItems.UIActionException : Window didn't respond, after waiting for 5000 ms
  ----> System.Exception : Timeout occured, after waiting for 5000 ms

我阅读了怀特有关等待的文档,但它说要查看配置"部分以了解了解如何设置自己的超时值.并且该部分不存在.

I read White's doc about waiting, but it says to look at Configuration section to see how to set my own timeout values. And that section does not exist.

更新:我尝试创建一个名为TestStack.White.dll.config的文件,并将其放置在与TestStackWhite.dll和测试dll相同的目录中.内容:

Update: I tried creating a file called TestStack.White.dll.config and placed it in the same directory as TestStackWhite.dll and my test dll. The contents:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>

    <sectionGroup name="White">
      <section name="Core" type="System.Configuration.NameValueSectionHandler"/>
    </sectionGroup>
  </configSections>

  <White>
    <Core>
      <add key="WorkSessionLocation" value="." />
      <add key="PopupTimeout" value="5000" />
      <add key="SuggestionListTimeout" value="10000" />
      <add key="BusyTimeout" value="10000" />
      <add key="WaitBasedOnHourGlass" value="true" />
      <add key="UIAutomationZeroWindowBugTimeout" value="10000" />
      <add key="TooltipWaitTime" value="10000" />
      <add key="DragStepCount" value="4" />
    </Core>
  </White>
</configuration>

尽管如此,无论我是从NUnit还是VS + Resharper中运行测试,我仍然有5秒钟的超时时间.

Nevertheless, I'm still getting the 5 seconds timeout whether I run my test from inside NUnit or VS + Resharper...

推荐答案

可以在测试代码中以编程方式配置这些超时.例如:

These timeouts can be configured programmatically, in your test code. For example:

CoreAppXmlConfiguration.Instance.BusyTimeout = 20000;

要使用App.Config进行此操作,必须将此类文件关联到测试程序集.因此,在测试项目中添加App.Config并粘贴问题中的内容也可以.

To do it using an App.Config, such file must be associated to the test assembly. So adding an App.Config to my test project and pasting the content from the question works as well.

这篇关于如何配置TestStack.White超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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