【问题标题】:NUnit not specified as test runner for SpecFlowNUnit 未指定为 SpecFlow 的测试运行程序
【发布时间】:2012-08-19 18:14:53
【问题描述】:

在我的一生中,我无法将 SpecFlow 配置为使用 NUnit 作为测试运行器。 NUnit 未列在“工具”>“选项”>“SpecFlow 测试运行器”下拉列表中,并且“自动”设置未找到 NUnit。

我已尝试多次重新安装 NUnit 和 SpecFlow。尝试安装 SpecFlow 1.8.1 和 1.9 无济于事。尝试使用 app.config。我什至尝试过重新安装 Visual Studio 2010。

我只想让 SpecFlow 使用 NUnit (2.6.1)。有人可以帮忙吗?

【问题讨论】:

    标签: visual-studio-2010 nunit specflow


    【解决方案1】:

    Visual Studio->工具->扩展和更新->在线->搜索“测试适配器”->安装。

    http://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d

    迟到总比没有好。

    【讨论】:

    • 太棒了!谢谢。有人用 SpecFlow 试试这个吗?它本身很有用,因此+1。谢谢@user2282496
    【解决方案2】:

    尝试编辑单元测试项目的配置文件:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
      </configSections>
      <specFlow>
          <unitTestProvider name="NUnit" />
      </specFlow>
    </configuration>
    

    查看配置文档here

    【讨论】:

    • 做到了。没有帮助。 specflow 将测试正确地构建为 NUnit 测试,但我无法右键单击功能文件并选择运行场景。不知何故,SpecFlow 集成没有将 NUnit 视为测试运行器......
    【解决方案3】:

    SpecFlow 本身不提供测试运行器,如果您想右键单击 .feature 并运行它,则必须重新配置 SpecFlow 以使用 MSTest,它应该使用内置的 VS 运行器。

    如果您想使用 NUnit,则需要额外的工具。我会推荐 Resharper,但它不是免费的。这个article 应该可以帮助您选择一种从 VS 运行 NUnit 测试的方法。

    祝你好运

    【讨论】:

      【解决方案4】:

      要与 Visual Studio 集成,您需要安装 SpecFlow 扩展。 SpecFlow 分为两部分。

      1. NuGet 包包含编写和运行测试所需的 dll。
      2. Visual Studio 扩展,它为您提供智能感知、语法突出显示、代码导航以及通过右键单击并选择“运行 SpecFlow 场景”来运行测试的能力。

      我猜你已经安装了 Nuget 包,但还没有安装扩展。

      要安装扩展:

      1. 打开 Visual Studio
      2. 选择工具 -> 扩展管理器
      3. 搜索 SpecFlow 扩展
      4. 点击安装

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-12-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-14
        • 2021-10-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多