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

Notification

Icon
Error

Usability issue with navigating to MSpec test which use behaviors
ljohnston
#1 Posted : Friday, January 17, 2014 7:04:45 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/17/2014(UTC)
Posts: 31

Thanks: 17 times
Was thanked: 5 time(s) in 5 post(s)
Place the following MSpec classes in separate files.

Code:

[Subject(typeof(fake))]
public class fake {
    protected Behaves_like<FailSpecificationBehavior> a_failure;
}

[Behaviors]
public class FailSpecificationBehavior {
    It should_fail = () => true.ShouldBeFalse();
}


Setup NCrunch/MSpec and allow the test to run.

Now open the NCrunch Tests window and select the test and right-click on it and select "Go to selected test".

I would expect this to navigate to the specification (possibly to the Behaves_like assertion), not to the assertion implementation in the underlying behavior. The vast majority of the time I navigate to a test it's because I want to debug or edit something in the specification, not the behavior implementation. The current behavior means that there's no way to navigate to the actual specification using NCrunch.
Remco
#2 Posted : Friday, January 17, 2014 10:36:03 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thank for sharing this issue.

I agree with you. The navigation to tests, especially in this situation, is not ideal. I'll try to explain why.

NCrunch itself is a language agnostic tool that extracts its test location and code coverage data using the debugging information generated by the compiler. The debug information only contains line numbers of physical lines of code, and does not contain the actual line numbers of class or method declarations. Because of this, it isn't possible for NCrunch to 'find' the true declaration of some tests - because they are inheriting or delegating structures that do not have debug information representing them.

In this specific case, NCrunch is navigating you to the closest line of code with debugging information that relates to the test you've written. It isn't the right spot - it's just the closest one we have enough information to get to.

To solve this problem properly would involve the introduction of some kind of partial C# compiler that is able to parse C# code and identify the location of specific elements within this code. There are some exciting developments coming in VS2014 in the form of Roslyn, which I hope will make it possible to improve how NCrunch currently handles this.
1 user thanked Remco for this useful post.
ljohnston on 1/17/2014(UTC)
ljohnston
#3 Posted : Friday, January 17, 2014 11:10:55 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/17/2014(UTC)
Posts: 31

Thanks: 17 times
Was thanked: 5 time(s) in 5 post(s)
Hi Remco,

Thank you for the information. It's interesting to get some insight into why this is a hard issue to fix.

It's great to hear that you're investigating Roslyn, hopefully it'll turn out to be useful for NCrunch and other developer tools.
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.029 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download