开发者

Disable timeout for unit tests in C#

I'm running into an issue where my tests timeout after 30 minutes. Any id开发者_StackOverfloweas on setting infinite timeout? I've tried Timeout(0), but it still throws a timeout after 30 minutes.

I'm running these unit tests in Visual Studio 2008.


Since 30 minutes is the default timeout for a unit test in the Visual Studio test framework, I'm going to take a guess that this is what you're referring to. If not, please provide more details.

You can set this timeout in at least two ways:

  1. Decorate specific TestMethods with an attribute: [Timeout(TestTimeout.Infinite)]; or
  2. Using Test -> Edit Test Settings -> [settings you're using] -> Test Timeouts.

Note that if you do this using (2), you will have to close and re-open your solution in VS before the change is applied.


It worked for me. You have to add it to the C# test code, just above the test method:

[Timeout(TestTimeout.Infinite)]
[TestMethod()]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜