'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:
- I create a project as a class library in the .NET Framework
- I add spec-flow to the project
- I add the NuGet Nunit test adapter and Nunit Framework (version3)
- I generate the .feature file
- I generate the file steps associated with the feature.
- 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?
Solution 1:[1]
Install the "SpecFlow.Tools.MsBuild.Generation" nuget package and rebuild the solution. That should get you going.
Solution 2:[2]
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.
Solution 3:[3]
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
Solution 4:[4]
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)
Solution 5:[5]
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)
Solution 6:[6]
It is better for you to use visual studio 2015 to do the same things that you want.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | meza |
Solution 2 | Andreas Willich |
Solution 3 | user1207289 |
Solution 4 | Brian Løkke Borg |
Solution 5 | Andrew |
Solution 6 | Fahim Uz Zaman |