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() { ...}
From stackoverflow
-
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)...
George Mauer : AFAIK == As Far As I Know? Man we're getting silly with these internet acronyms. Thanks though! -
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.
George Mauer : Didn't even know that a new one is out, upgrading is fun
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.