问题
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
回答1:
The console runner is for running specs from the command line. You need the Visual Studio MSTest runner installed.
回答2:
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
来源:https://stackoverflow.com/questions/32231272/why-does-visual-studio-2015-console-runner-not-recognize-mspecs