Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

disable timeouts when debugging
sferencik
#1 Posted : Thursday, April 25, 2013 12:49:40 PM(UTC)
Rank: Member

Groups: Registered
Joined: 4/4/2013(UTC)
Posts: 16
Location: Czech Republic

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
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.)
Remco
#2 Posted : Thursday, April 25, 2013 11:42:03 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
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
realmforge_studios
#3 Posted : Friday, April 26, 2013 4:13:36 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/23/2013(UTC)
Posts: 6
Location: Germany

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"
Remco
#4 Posted : Saturday, April 27, 2013 12:34:32 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
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.
Remco
#5 Posted : Thursday, July 4, 2013 7:08:36 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
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).
1 user thanked Remco for this useful post.
GreenMoose on 9/27/2013(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.043 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download