1

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?

I Bowyer
  • 691
  • 1
  • 9
  • 21

1 Answers1

2

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)]
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • @Cace - We are using TFS 2015 (in house version) here and on looking at the Definition it has the build step "Visual Studio Test" and not "Test Assembles". Looking through Definition again there is "Run Settings File" Can I point it to a TestSettings config where I think I can set a timeout. I'm going to check that out later – I Bowyer Sep 01 '16 at 09:07
  • 1
    "Test Assembles" is the task name in TFS15 and VSTS. It's supposed to be the same as "Visual Studio Test" in TFS 2015 :-). You may try setting timeout in testsettings file as runsettings file doesn't have timeout property. – Cece Dong - MSFT Sep 02 '16 at 02:29