本文介绍了如何在 Visual Studio 2010 中运行 SpecFlow 测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用全新的 VS2010 Professional 安装来运行 SpecFlow.创建了一个新的控制台应用程序并添加了对 NUnit 和 SpecFlow 的引用.创建了 SpecFlow 功能.创建了具有默认模板代码的 .feature.

Trying to get SpecFlow running with a fresh VS2010 Professional install. Created a new console application and added references to NUnit and SpecFlow. Created a SpecFlow feature. The .feature with the default template code is created.

现在我尝试运行此测试,但我不明白如何运行.当我右键单击项目(在顶层)时,鼠标下拉菜单中没有运行测试"选项.SpecFlow 没有正确安装,我是否缺少一些参考资料或需要安装的其他工具?

Now I try to run this test, but I don't understand how. When I right-click the project (at the top-level), there is no "Run test(s)" option in the mouse drop down menu. Didn't the SpecFlow install correctly, am I missing some references or some other tool I need to install?

推荐答案

如果您希望能够直接从 Visual Studio 2010 运行您的测试而不需要任何其他工具或扩展,那么您应该将 SpecFlow 配置为使用 MsTest 作为其单元测试框架.

If you want to be able to run your tests directly from Visual Studio 2010 without any additional tools or extensions than you should configure SpecFlow to use MsTest as its unit test framework.

这可以在您的应用程序配置文件中使用以下内容完成:

This can be done in your application configuration file with the following:

  <configSections> 
    <section 
       name="specFlow" 
       type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/> 
  </configSections> 
  <specFlow> 
    <unitTestProvider name="MsTest" /> 
    <!--
        Use this if you're running VS2010
        <unitTestProvider name="MsTest.2010" />
    -->
  </specFlow> 

生成的代码隐藏文件将包含 Visual Studio 可识别的 MsTest 测试,并且可以使用 build-it 测试运行器运行.

The generated code-behind file will then contain MsTest tests that are recognisable by Visual Studio and can be run with the build-it test runner.

根本不需要使用 NUnit.

No need to use NUnit at all.

这篇关于如何在 Visual Studio 2010 中运行 SpecFlow 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 20:16