简体   繁体   中英

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.

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. 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. Currently this is 60 minutes.

What I am wanting is a "unit test timeout".

Can this be configured in 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. If you use VSTS or TFS15, you can specify the timeout for the test task directly in build definition, check the screenshot below:

在此处输入图片说明

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:

[TestMethod(),Timeout(10000)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM