4

I've written some MSpecs, but Visual Studio (2015) test runner does not recognize them. I've added the Machine.Specifications.Runner.Console and all required Machine.Specification-packages using the NuGet-PM. But when I choose Test->Run Test, the mspec-containing file is not even listed. Beyond is an example of the mspecs I wrote so far, which is located in an own project/solution that contains some other (regular unit) test, which all run fine btw.

[Subject(typeOf(ControllerForm)]
public class When_file_with_multiple_procedures_is_opened:ControllerFormSpecs
{
   static ControllerForm subject;
   ...
   Establish context =()=>
   {
       subject = new ControllerForm(...);
       path="someRandomPath";
   };

   Because of =()=>
   {
       subject.OpenFile(path);
   }

   It should_have_event =()=> subject.eventExist.ShouldBeTrue();

   It should_not_have_data  =()=> subject.currentNode.ShouldBeNull();

   Cleanup after =()=>
   {
       subject = null;
   };
 }

What am I missing?

Note: Using ReSharper is not an option here. I know many people like it and even more recommend it, but my company allready declined my request for that.

edit: Using the 'Machine.Specifications.Console.Runner' you got to keep the following in mind:

1) Change the working directory of the console to the very one, where all mespc.exe files are stored (in my case: c:\projects\...\Source\packages\Machine.Specifications.Runner.Console.versionnumber\tools)

2) Choose the right .exe-file depending on your debug-options (in my case: mspec-x86.exe)

3) as parameter you now have to insert the relative path to the .dll of the very project that contains the mspecs. ( again as example for my case: ..\..\..\PluginTests\bin\x86\Debug\PluginTests.dll

krouch
  • 105
  • 9
  • Wrong runner. Just [RTFM](https://github.com/machine/machine.specifications), it shows how to use mspec.exe to run tests. The lack of decent VS integration is your cross to bear. – Hans Passant Aug 26 '15 at 16:14
  • I`ve read the f***ing manual, though I was hoping VS would integrate mspecs in a useful way somehow. No need for aggression ;) – krouch Aug 27 '15 at 06:35

3 Answers3

1

The console runner is for running specs from the command line. You need the Visual Studio MSTest runner installed.

Tim Long
  • 13,508
  • 19
  • 79
  • 147
1

In case others are struggeling with this as well, using https://visualstudiogallery.msdn.microsoft.com/4abcb54b-53b5-4c44-877f-0397556c5c44 Visual Studio was able to recognize the mspecs. However the results are not displayed. So if you can't/won't afford ReSharper I highly recommend the plain console runner

krouch
  • 105
  • 9
  • And now [Machine.VSTestAdapter](https://visualstudiogallery.msdn.microsoft.com/f8d80e41-0a85-4b04-aa41-0bc59dc81a5a) is the new updated runner. – Jakub Januszkiewicz Apr 01 '16 at 06:26
0

The accepted answer is a few years old now, and to update it with some Visual Studio 2019 / Resharper 2019.3.4+ info, the above wasn't successful for me, instead what worked is using Resharper's inbuilt extensions manager.

In VS, go to:

Extensions -> ReSharper -> Extension Manager

and search/install "Machine.Specifications for ReSharper"

DaveDean1
  • 59
  • 1
  • 5