为什么我的 SpecFlow 测试没有显示在 Visual Studio 测试窗口中? [英] Why do my SpecFlow tests not show up in Visual Studio Test window?

查看:17
本文介绍了为什么我的 SpecFlow 测试没有显示在 Visual Studio 测试窗口中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了 SpecFlow 的入门教程.一切正常,除了我有 @SpecRun 测试,因为我没有输入演示密钥.

I have gone through the Getting Started tutorial for SpecFlow. Everything worked fine except that I have the @SpecRun test because I have not entered a demo key.

但在我们的主要项目中,我们使用 NUnit 而不是 SpecFlow+ Runner.所以我试图模仿那个项目.如果您使用 NUnit,则不需要演示密钥.所以我将单元测试提供程序更改为:

But in our main project we use NUnit instead of SpecFlow+ Runner. So I tried to mimic that project. If you use NUnit you won't need the demo key. So I changed the Unit Test Provider to:

<specFlow>
  <unitTestProvider name="NUnit" />
</specFlow>

我还将我的教程参考与主要项目的参考进行了比较.我发现我可以取出 TechTalk.SpecRun 并且项目仍然会编译.当然需要 TechTalk.SpecFlow.

I also compared my tutorial references to the main project's references. I find that I can take out TechTalk.SpecRun and the project will still compile. Of course TechTalk.SpecFlow is needed.

如果我取出 SpecRun.SpecFlowPlugin,除了 @SpecRun 之外没有测试出现,这是没有演示密钥的测试延迟.

If I take out SpecRun.SpecFlowPlugin, no tests show up except @SpecRun which is the tests delay without the demo key.

我还在主项目中看到了一个名为:SpecFlowNUnitExtension.cs 的 csharp 文件.我引入了这个文件,但我的测试仍然没有显示在 Visual Studio 测试窗口中.我需要做些什么来注册这个文件?

I also see in the main project a csharp file called: SpecFlowNUnitExtension.cs. I brought in this file but my tests still do not show up in the Visual Studio Test window. Is there something I need to do to register this file?

推荐答案

您需要一个用于 Visual Studio 的测试运行器适配器才能在测试资源管理器中获取测试.它们由 NuGet 包分发.将测试运行器的包添加到测试项目中.

You need a test runner adapter for Visual Studio to get the tests in the test explorer. They are distributed by NuGet packages. Add the package for your test runner to your test project.

  • SpecFlow+Runner:SpecRun.Runner
  • NUnit2:NUnitTestAdapter
  • NUnit3:NUnit3TestAdapter
  • XUnit:xunit.runner.visualstudio
  • MsTest:不需要额外的适配器

这篇关于为什么我的 SpecFlow 测试没有显示在 Visual Studio 测试窗口中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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