简体   繁体   中英

The tests are not shown in specflow + nunit3 with Visual Studio 2017

I'm starting with BDD and spec-flow in C# and Visual Studio. I was following a tutorial at https://www.toolsqa.com/specflow/set-up-specflow/ to set up a project but I cannot be shown the tests in visual studio 2017 to run.

The steps I take are the following:

  1. I create a project as a class library in the .NET Framework
  2. I add spec-flow to the project
  3. I add the NuGet Nunit test adapter and Nunit Framework (version3)
  4. I generate the.feature file
  5. I generate the file steps associated with the feature.
  6. I compile the solution but in the test window I don't see any tests that run

I searched for several tutorials but I can't find what my mistake is or what I'm missing.

Can anyone help me?

Install the "SpecFlow.Tools.MsBuild.Generation" nuget package and rebuild the solution. That should get you going.

We have a "Getting started" guide on the website: https://specflow.org/getting-started/

Also we have some examples here: https://github.com/techtalk/SpecFlow-Examples

You could compare your project with the example if you missed something.

I had the same issue . And when I upgraded my specflow to 3.0.213 , feature.cs and tests were not generated in test explorer. Then I used this MSBUild example with latest specflow to generate feature.cs and tests in test explorer. It uses MSTest as test runner and not Nunit. If test runner doesn't matter to you, use this example. I am running it on visual studio 2019

Had the same issue,

Besides adding the nuget package

SpecFlow.Tools.MsBuild.Generation

as Meza mentioned.

The testes did not appear in the Test Explorer before i added

SpecFlow.NUnit.Runners

besides already having

SpecFlow

SpecFlow.NUnit

NUnit

NUnit3TestAdapter

and the Visual Specflow extension

(VS2019, Specflow 3.1.67)

As an update these were the nuget packages I had in place to finally get an example working, using selenium running under NUnit. (It may be useful to someone)

在此处输入图像描述

您最好使用 Visual Studio 2015 来做您想做的事情。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM