简体   繁体   English

如何设置要在TFS Build Server中运行的单元测试的超时

[英]How can I set the Timeout for a unit test takes to run in TFS Build Server

Recently we have had an issue where a unit test started to take 20+ minutes to run when on the build server. 最近,我们遇到了一个问题,即在构建服务器上进行单元测试需要花费20分钟以上的时间。

I have now fixed that issue but I wondered if there was a way to fail the test when running a CI build on TFS server if a test reaches a certain time limit. 我现在已经解决了该问题,但是我想知道如果测试达到一定的时间限制,那么在TFS服务器上运行CI构建时是否有一种方法可以使测试失败。 I've looked at the Definition in TFS and the only timeout I can configure is the "Build job timeout in minutes" which is for the whole project. 我已经看过TFS中的定义,并且我可以配置的唯一超时是针对整个项目的“以分钟为单位的构建作业超时”。 Currently this is 60 minutes. 目前是60分钟。

What I am wanting is a "unit test timeout". 我想要的是“单元测试超时”。

Can this be configured in TFS? 可以在TFS中配置吗? or do I need to set it in my test settings for the solution? 还是需要在解决方案的测试设置中进行设置?

The feature of timeout a task has already existed in VSTS and new TFS15RC1. VSTS和新的TFS15RC1中已经存在任务超时的功能。 If you use VSTS or TFS15, you can specify the timeout for the test task directly in build definition, check the screenshot below: 如果使用VSTS或TFS15,则可以直接在构建定义中指定测试任务的超时,请检查以下屏幕截图:

在此处输入图片说明

If you use TFS 2015, there is not a direct way to set timeout for a task in build definition, but you can set the timeout for each TestMethod in your Unit Test project, for example: 如果使用TFS 2015,则无法直接在构建定义中为任务设置超时,但是您可以为单元测试项目中的每个TestMethod设置超时,例如:

[TestMethod(),Timeout(10000)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在TFS 2010的Build-Deploy-Test构建中运行许多单元测试? - How do I run many unit tests in Build-Deploy-Test build in TFS 2010? TFS构建上的SQL Server单元测试 - SQL server unit test on TFS build 如何使单元测试作为TFS2008构建的一部分运行? - How can I get unit tests to run as part of a TFS2008 build? 如何对一个在循环中使用stdin的方法进行单元测试? - How can I unit test a method that takes stdin within a loop? 有谁知道如何在TFS 2010中为源代码的选定部分设置单元测试签到策略? - Does anyone know how I can set unit test check-in policy for a selected portion of my source code in TFS 2010? 如何针对MS Test中的接口的两种不同实现运行一组单元测试? - How can I run a set of unit tests against two different implementations of an interface in MS Test? MSTest中的ClassCleanup是静态的,但是构建服务器使用nunit来运行单元测试。 我该如何调整? - ClassCleanup in MSTest is static, but the build server uses nunit to run the unit tests. How can i adjust? 如何为每个C#TestMethod单元测试自动创建TFS测试用例 - How can I automate creation of TFS Test Case's for each C# TestMethod Unit Test 如何强制在Gradle Android构建上运行单元测试? - How can I enforce that unit tests are run on Gradle Android build? 如何在浏览器环境中运行单元测试? - How can I run a unit test in a browser environment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM