tags:

views:

53

answers:

2

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() { ...}
+1  A: 

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

Arnshea
AFAIK == As Far As I Know? Man we're getting silly with these internet acronyms. Thanks though!
George Mauer
+2  A: 

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.

tvanfosson
Didn't even know that a new one is out, upgrading is fun
George Mauer