问题描述
我已经编写了一些MSpec,但是Visual Studio(2015)测试运行程序无法识别它们.我已经使用NuGet-PM添加了Machine.Specifications.Runner.Console
和所有必需的Machine.Specification
-程序包.但是,当我选择Test->Run Test
时,甚至没有列出包含mspec的文件.除此以外,是我到目前为止编写的mspec的一个示例,该示例位于一个自己的项目/解决方案中,该项目/解决方案包含一些其他(常规单元)测试,这些测试都可以正常运行.
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;
};
}
我想念什么?
注意:此处不提供使用ReSharper的选项.我知道很多人喜欢它,甚至更多地推荐它,但是我的公司已经拒绝了我的请求.
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.
使用'Machine.Specifications.Console.Runner'您必须牢记以下几点:
edit: Using the 'Machine.Specifications.Console.Runner' you got to keep the following in mind:
1)将控制台的工作目录更改为一个目录,其中存储了所有mepcc.exe文件(在我的情况下为c:\projects\...\Source\packages\Machine.Specifications.Runner.Console.versionnumber\tools
)
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)根据您的调试选项选择正确的.exe文件(在我的情况下为mspec-x86.exe
)
2) Choose the right .exe-file depending on your debug-options (in my case: mspec-x86.exe
)
3)现在,您必须将相对路径插入包含mspecs的项目的.dll. (再次以我的情况为例:..\..\..\PluginTests\bin\x86\Debug\PluginTests.dll
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
推荐答案
控制台运行程序用于从命令行运行规范.您需要安装Visual Studio MSTest运行程序.
The console runner is for running specs from the command line. You need the Visual Studio MSTest runner installed.
这篇关于为什么Visual Studio 2015控制台运行程序无法识别MSpec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!