如何使VS2010识别由SpecFlow生成的mstest? [英] How to get VS2010 to recognize my mstests generated by SpecFlow?

查看:101
本文介绍了如何使VS2010识别由SpecFlow生成的mstest?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过在我的"specs"类库的app.config中像这样指定它来将Specflow配置为以MsTest框架(而不是NUnit)为目标:

I have configured Specflow to target the MsTest framework (instead of NUnit) by specifying it like this in the app.config of my 'specs' class library:

<configSections>
    <section name="specFlow"
   type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
</configSections>

<specFlow>
 <unitTestProvider name="MsTest.2010" />
</specFlow>

因此,一旦安装到位,我可以看到我的测试夹具是由Specflow定制工具正确生产的,带有正确的TestClassAttribute()和方法等:

So once it's in place, I can see that my test fixtures are produced correctly by the Specflow custom tool, with correct TestClassAttribute() and methods, etc:

[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.3.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute()]
...

specs类已生成,但是现在我无法在Vista 64盒上使用Visual Studio 2010内部的测试->运行->解决方案中的所有测试"来运行测试. VS为什么不将这些识别为有效的测试来运行?

The specs class builds, but now I cannot run the tests using the Test --> Run --> All Tests in Solution inside Visual Studio 2010 on my vista 64 box. Why doesn't VS recognize these as valid tests to run?

推荐答案

我不得不将项目重新创建为Test Project,而不仅仅是Class Library-因为我已经开始使用NUnit和SpecFlow进行开发,所以我创建了一个普通的类库来保存我的带有NUnit属性装饰的规范.我以为我可以简单地更改此现有项目的app.config,使其指向mstest框架并停止使用NUnit,但是VS2010始终无法识别测试,尽管通过specflow的自定义工具正确创建了存根.

I had to recreate the project as a Test Project and not merely a Class Library -- because I had started development with NUnit and SpecFlow, I had created a vanilla class library to hold my specs that had the NUnit attributes decorated. I thought I could simply change the app.config of this existing project to point at the mstest framework and stop using NUnit, but VS2010 never recognized the tests, despite the correct creation of the stubs by specflow's custom tool.

所以...我在解决方案中添加了一个新的Test Project,将所有规范代码移至该新项目,然后重新编译,中提琴,VS2010可以识别测试.我确定它正在.csproj文件的XML中寻找一个GUID,或者告诉它连接测试框架的东西,但我没有做那么深入.

So...I added a new Test Project to my solution, moved all of my spec code to that new project, then recompiled, and viola, VS2010 recognizes the tests. I'm sure there is a GUID it is looking for in the XML of the .csproj file or something that tells it to wire up the testing framework, but I didn't dig that far.

希望这对某人有帮助.

这篇关于如何使VS2010识别由SpecFlow生成的mstest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆