23
  1. I set up the SpecFlow plug-in for the Visual Studio 2013.
  2. I created new Feature Item and build it.

Result: built test is not shown in the Test Explorer. Why?

I do it according to this video

Emzor
  • 1,380
  • 17
  • 28
Vlad Kostyukevich
  • 463
  • 1
  • 3
  • 12

10 Answers10

23

in order to configure it to generate MSTest tests you need to add this to your app.config:

<specFlow>    
  <unitTestProvider name="MSTest"></unitTestProvider>
</specFlow>
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
23

I experience this same problem, but the solution was different.

Following the advice on a SpecFlow Github issue, the following worked for me:

  1. Close all Visual Studio instances
  2. Go to %TEMP%\VisualStudioTestExplorerExtensions\
  3. Delete all the folders in here
  4. Try again
ngm
  • 7,277
  • 1
  • 53
  • 62
17

if the tests are not showing in the test explorer you need to install NUnit test adapter :

go to Tools->Extensions and updates ->Online->Visual Studio Gallery->Tools->Testing and select NUnit Test Adapter

Sonja
  • 575
  • 1
  • 6
  • 20
  • 1
    then the tests d=should appear in the test explorer. I had the same problem. but only you should wait few mins if there are many tests. You can also uninstall and reinstall NUnit Test Adapter – Sonja Apr 25 '17 at 11:45
5

Visual Studio can change the default processor architecture when it loads. While looking endlessly trying to figure out the issue, I finally figured it out, that it wasn't really Specflow causing the issue.

If you have references that require a special architecture, it will prevent the tests from showing up in the test explorer. Change the architecture to x86 or x64 based on your needs.

Another thing you can do to see the build issues is open the Output window and change the dropdown to Tests during build. It will highlight any information of things taking place during your build.

I felt somebody should mention it just in case.

osoclever
  • 373
  • 7
  • 16
2

I'm running SpecFlow tests with SpecRunner and had this same problem, a couple of times as a matter of fact. Having tried all of the above suggestions, I found that the only solution to the problem was to uninstall and reinstall the SpecRun NuGet package. Next build, tests present in Test Explorer window as expected.

The Furious Bear
  • 592
  • 4
  • 16
  • 31
2

In my case the reason why tests weren't discovered were because I was using Resharper build.
As soon as I went to: Resharper -> Options -> Tools -> Build -> General: "Use ReSharper Build"(untick), then all tests were suddenly discovered.

HamsterWithPitchfork
  • 750
  • 1
  • 12
  • 21
2

In my case all the approaches above didn't work. My solution: I don't know why, but - I re-installed "Specflow for Visual Studio 2015" in "Tools => Extensions and Updates", then I've created a new feature file (old still didn't work), and this new feature-file works correctly.

Ustin
  • 568
  • 6
  • 19
2

For me, I changed from using direct DLL references to using the NuGet references of version 3.1.7.4 of SpecFlow and this solved the problem.

I needed to reference "SpecFlow", "SpecFlow.NUnit" and "SpecFlow.Tools.MsBuild.Generation". and then clicked the "Show All Files" button in Visual Studio to see the code behind file at a sibling level to it associated Feature file (this used to be an associated child file of the feature file in older versions).

I also need to use the "Include In Project" context menu item on the code behind file, for tests to show up in Visual Studios "Test Explorer".

NOTE: I did try to unzip the Specflow required files from the NuGet package and reference them directly in my project to be consistent with other direct references in my project (non-NuGet references) but this doesn't seem to work and you have to use the NuGet reference. I found an closed issue in github, which states that we have to use the Nuget reference to get the tests to work in Test Explorer: https://github.com/techtalk/SpecFlow/issues/1617

Mike
  • 827
  • 11
  • 27
1

For me, the issue was the TestAssemblyPath in my srprofile file. It didn't match my actual dll name.

kevinpo
  • 1,853
  • 19
  • 20
0

I tried installing the Nugget package

SpecFlow.Tools.MsBuild.Generation

with the same version than specflow and now I can see the test in TestExplorer, other ways not works for me.

I already had installed 1 from

Nugget Package Specflow
Specflow.NUnit
Nunit
Nunit3TestAdapter

and the extension for Visual Studio for Specflow a NUnitTestAdapter

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
Rose8525
  • 109
  • 6