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

Notification

Icon
Error

MSpec with Behaviors does not 'Go to selected Test'
shamp00
#1 Posted : Wednesday, March 27, 2013 11:08:07 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/25/2012(UTC)
Posts: 3
Location: London, United Kingdom

Thanks: 1 times
I can't find an easy way to jump to a failing spec when the spec uses Behaves_Like<>.

When I double click on a test or right-click and 'Go to selected test' in the NCrunch output window, I get taken to the Behavior rather than the spec.

For example, with the following failing spec:

Code:

[Behaviors]
public class Any_day_except_monday
{
    protected static string _mood;

    It should_be_OK = () => _mood.ShouldEqual("Ok");
}

[Subject(typeof(MoodIdentifier)), Tags("Behavior")]
public class Given_the_current_day_is_tuesday_when_identifying_my_mood : WithSubject<MoodIdentifier>
{
    protected static string _mood;
    Behaves_like<Any_day_except_monday> any_day_except_monday;

    Establish context = () =>
    {
        var monday = new DateTime(2011, 02, 14);

        The<ISystemClock>().WhenToldTo(x => x.CurrentTime).Return(monday);
    };

    Because of = () =>
    {
        _mood = Subject.IdentifyMood();
    };
}


Then in the output window I see the following

[img=(- BROKEN LINK -)]NCrunch output[/img]
Remco
#2 Posted : Wednesday, March 27, 2013 8:41:42 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for posting!

Although this behaviour is not ideal at all, it is, quite sadly, the best approach available given the design of NCrunch.

NCrunch's analysis and test discovery is all entirely post-build, which means that its ability to navigate to tests is constrained by the debugging information output by the compiler. This is very different to tools such as CodeRush and Resharper, which pre-compile code and can therefore have access to information about the specific locations of tests along with their structure.

Where a test is derived from a class and not a method (as is the case with normal fixture tests, or MSpec behaviors), NCrunch has no reliable debugging information to mark the location of the class within your source code - hence there is no navigation target available.

I'm sorry, I wish I could say that it was possible to fix this, but to do so would require massive amounts of new development (i.e it would basically be like turning NCrunch into a refactoring tool).


Cheers,

Remco
1 user thanked Remco for this useful post.
shamp00 on 3/28/2013(UTC)
shamp00
#3 Posted : Wednesday, April 3, 2013 3:09:19 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/25/2012(UTC)
Posts: 3
Location: London, United Kingdom

Thanks: 1 times
My solution at the moment is to do `Ctrl+,`to open 'navigate to' and then type in the name of the class.

How about a right-click 'search' which just issues this same class name search?

Some of my behaviors are reused by dozens of classes so anything would help...
Remco
#4 Posted : Wednesday, April 3, 2013 10:01:48 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
I'll have a bit of a think around this to see if there's clean ways to solve this. There are other future feature areas NCrunch may explore that would open up opportunities here. Thanks for sharing the issue and the suggestions!
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.037 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download