Build/Test Issues

MSpec with Behaviors does not 'Go to selected Test'

Started by shamp00 on 6,671 views

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:


[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]
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
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...
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!

Post a reply

Log in to reply.