views:

564

answers:

2

I'm having a problem getting ReSharper to see the Machine.Specification "tests" I've written.

The specs run in the ConsoleRunner from mSpec. When I try to "Run Unit Tests" in ReSharper, I get a message: "No tests found in file." The specs don't show the test markers.

I created a folder in the ReSharper /bin/ folder and put the proper .dlls there. The mSpec plug in appears in ReSharper.

What might I be missing?

Also, I'm using xUnit.NET if that makes a difference.

+3  A: 

The ReSharper runner do not take nested context classes into account. Instead of nesting context classes:

namespace SomeNamespace
{
    public class Specs
    {
        public class when_something_happens
        {
            Because of = () => {};
            It should_do_something = () => {};
        }
    }
}

Author contexts that are not nested, i.e. root classes inside a namespace:

namespace SomeNamespace
{
    public class when_something_happens
    {
        Because of = () => {};
        It should_do_something = () => {};
    }
}

ReSharper's green-and-yellow test icons do appear if all of the conditions are met:

  • class is public
  • class is not abstract
  • class is not nested
  • has >= 1 specification field (It), or has >= 1 behavior field (Behaves_like<>)
Alexander Groß
Thanks for the answer; and the help via Twitter.
y0mbo
+1 Yikes. Is there any other way?!?!?! So, I stumbled upon what a ReSharper unit test report looks like and am impressed, and I also had the same issue as the author. Thing is, I have over 200 classes (over 2500 'Specs' in MSpec), they inherit abstracted logic/helpers and such. Yes, it can all be refactored around. But I have a concern around the Contextes being shared (more refactoring!) and how the MSpec report will order things.
eduncan911
I wrote a version of the ReSharper runner that supports nested contexts - we're still considering putting this in the official master.http://github.com/agross/machine.specifications/tree/nestedtypesStill, IMHO namespaces are the preferred method to structure contexts.
Alexander Groß
A: 

In order to have good integration of MSpec with Visual Studio and ReSharper install MSpec using installer which is available here: http://marcinobel.com/index.php/mspec-bdd-installer/

Marcin Obel

related questions