I Bowyer
I Bowyer

Reputation: 823

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?

Upvotes: 1

Views: 1235

Answers (1)

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31023

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:

enter image description here

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)]

Upvotes: 2

Related Questions