Reputation: 122212
I would like to be able to fail the test if the executing code hangs. Is there a way to do this currently?
I am thinking something like the following must exist, but I can't seem to find it in the API
[Test, Timeout(TimeSpan.FromSeconds(2))]
public void Test() { ...}
Upvotes: 0
Views: 115
Reputation: 532695
Are you using NUnit 2.5? A TimeoutAttribute was added in NUnit 2.5 that does exactly what you want, though you specify the timeout in milliseconds. See the release notes.
Upvotes: 2
Reputation: 11243
AFAIK there's nothing built into NUnit that'll do this but it should be easy enough to do with DateTime (or performance counters if you're wanting higher resolution timers)...
Upvotes: 1