[英]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.