General Feedback

disable timeouts when debugging

Started by sferencik on 10,523 views

AFAIK, newer versions of NUnit disable the TimeoutAttribute when an interactive debugger is attached.

http://xunit.codeplex.com/workitem/9823
https://bugs.launchpad.net/nunitv2/+bug/543517

Is this something that NCrunch should be able to do? Or does this depend on the NUnit that NCrunch uses? (It seems NCrunch correctly disables its own timeout, the one that defaults to 60 s.)

Edited

In theory, NCrunch should already be doing this. Before attempting to abort test execution due to timeout, NCrunch will make a call to Debugger.IsAttached to see whether there is a debugger attached, and if so, it won't abort. The NUnit timeout mechanism relies on the version of NUnit that is being used, which should be the 2.6.2 version packaged with NCrunch. So if you're getting timeouts with the debugger attached, it means that something is going wrong here. When you receive a timeout message, are you able to post it here?

Thanks!

Remco
I am experiencing the same problem. Here is a simple test case to reproduce the problem:

[TestFixture]
public class Test
{
[Test]
[Timeout(1)]
public void TestTimeout()
{
}
}


Put a breakpoint in the line with the openinig bracket { for TestTimeout function and debug the test. Then do any debugger step and the test case will be stopped (by NUnit). The test message is just

"Test exceeded Timeout value of 1ms"
Thanks for the test case. This also triggered a time out for me, so there's definitely an issue here.

It looks as though the Thread.Abort is being kicked up by NUnit. I'll need to do some digging to see if I can find a way to suppress this behaviour within NUnit.

If you're using NCrunch as your primary test runner, you may be able to work around this issue by using NCrunch.Framework.TimeoutAttribute instead of the NUnit timeout attribute. NCrunch will enforce timeouts using its own attribute, but NUnit will ignore the attribute, allowing the test to continue running with a debugger attached.
It looks as though the latest version of NUnit had the Debugger.IsAttached functionality disabled - https://bugs.launchpad.net/nunitv2/+bug/543517.

It isn't yet clear why this is the case, but unfortunately NCrunch has no way to override this behaviour as it is completely under the control of NUnit.

If anyone is being affected by this issue, I recommend subscribing to the bug link above to help make Charlie more aware of it. As described, you can also work around this problem by avoiding use of NUnit timeout attributes and using the NCrunch.Framework timeout attribute instead (which will be enforced by NCrunch rather than NUnit).

Post a reply

Log in to reply.