SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.24k stars 754 forks source link

Specflow Test not appearing in Test Explorer #1559

Closed swakita14 closed 3 years ago

swakita14 commented 5 years ago

Specflow Tests not appearing in Test Explorer

SpecFlow Version:

Used Test Runner

Version number: 3.0

Visual Studio Version

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

<SpecFlow> Section in app.config or content of specflow.json

<?xml version="1.0" encoding="utf-8"?>
<configuration>

</configuration>

packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="BoDi" version="1.4.1" targetFramework="net472" />
  <package id="FluentAssertions" version="5.6.0" targetFramework="net472" />
  <package id="Gherkin" version="6.0.0" targetFramework="net472" />
  <package id="NUnit" version="3.11.0" targetFramework="net472" />
  <package id="NUnit.Console" version="3.9.0" targetFramework="net472" />
  <package id="NUnit.ConsoleRunner" version="3.9.0" targetFramework="net472" />
  <package id="NUnit.Extension.NUnitProjectLoader" version="3.5.0" targetFramework="net472" />
  <package id="NUnit.Extension.NUnitV2Driver" version="3.6.0" targetFramework="net472" />
  <package id="NUnit.Extension.NUnitV2ResultWriter" version="3.5.0" targetFramework="net472" />
  <package id="NUnit.Extension.TeamCityEventListener" version="1.0.3" targetFramework="net472" />
  <package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net472" />
  <package id="NUnit3TestAdapter" version="3.13.0" targetFramework="net472" />
  <package id="Selenium.Chrome.WebDriver" version="74.0.0" targetFramework="net472" />
  <package id="Selenium.Support" version="3.141.0" targetFramework="net472" />
  <package id="Selenium.WebDriver" version="3.141.0" targetFramework="net472" />
  <package id="SpecFlow" version="3.0.213" targetFramework="net472" />
  <package id="SpecFlow.NUnit" version="3.0.213" targetFramework="net472" />
  <package id="SpecFlow.NUnit.Runners" version="3.0.213" targetFramework="net472" />
  <package id="SpecFlow.Tools.MsBuild.Generation" version="3.0.213" targetFramework="net472" />
  <package id="System.Reflection.Emit" version="4.3.0" targetFramework="net472" />
  <package id="System.Reflection.Emit.Lightweight" version="4.3.0" targetFramework="net472" />
  <package id="System.Threading.Tasks.Extensions" version="4.4.0" targetFramework="net472" />
  <package id="System.ValueTuple" version="4.4.0" targetFramework="net472" />
  <package id="Utf8Json" version="1.3.7" targetFramework="net472" />
</packages>

Repro Project

Issue Description

Seems to be the case that there is an option that runs/tests the senario, but the option is not available (not there) when I right click the Senario

Steps to Reproduce

SabotageAndi commented 5 years ago

Ok, what is now the issue? That no tests are in the test explorer or that the context menu entry is not there?

swakita14 commented 5 years ago

The main problem would be that the tests are not showing up in the test explorer. This is what the Senario options are if that helps image

SabotageAndi commented 5 years ago

Please create a small repro project. From the info I have now, I don't know why the scenarios aren't showing up in the test explorer.

The context menu was removed with the 2019.* VS Extension. See https://specflow.org/2019/changes-to-the-specflow-visual-studio-extension/

swakita14 commented 5 years ago

This the way I have to project orgaznied as of now. image

If I have the features and the steps in a different folder, the test explorer doesnt recognize them, but once I drag them out of the folder in this manner, I get the tests to be recognized by the test explorer image

SabotageAndi commented 5 years ago

Ok, thats a good hint with the folder.

SabotageAndi commented 5 years ago

I had a look at it, but I couldn't reproduce the behaviour.

Here is the test project for it: https://github.com/SabotageAndi/SpecFlow_OldCSProj_FeatureInSubfolder

Could you check this project if it is working for you?

Rain9333 commented 5 years ago

With your project @SabotageAndi they appear in the Test Explorer (also works with mine project) although sometimes in takes more time or need 1-2 build/rebuilds.

But I have another issue that I can't resolve. Same env like the author (VS 2017 latest, .net 4.5+, SpecFlow 3.0.213 NUnit test provider. All seems to be working correctly but double-click from test explorer no longer redirect me to the scenario like before. Any ideas about that?

SabotageAndi commented 5 years ago

@Rain9333 the issue with the navigation is here: https://github.com/techtalk/SpecFlow/issues/1457

chaturvediankit commented 4 years ago

Hi,

I am facing same issue that new project created in VS 2017, test's are not appearing in test explorer after building project ?

bincygijo commented 4 years ago

I am experiencing the same problem that I created a new project in Visual Studio 2017,tests are not displaying in test explorer.

JigeshShah commented 4 years ago

Same issue

jwmxyz commented 4 years ago

Having the same issue in VS2019

chaturvediankit commented 4 years ago

@jwmxyz @JigeshShah @bincygijo Hi All, I was able to resolve this issue by following below steps. .NET Core

  1. Create New Project as Class Library
  2. Added only Below Dependency image
  3. Added Extension "SpecFlow for Visual Studio 2019"
  4. Build Solution and started reflecting .NET Framework
  5. Create New Project as Class Library
  6. Added only sameDependency
  7. Added Extension "SpecFlow for Visual Studio 2017/2019"
  8. Single File Generator-> False (You Can find in feature file Property)
  9. Enable Tracing (Tools--> Options--> SpecFlow)
jwmxyz commented 4 years ago

@chaturvediankit I think i just needed to include the SpecFlow.Tools.MsBuild.Generation. That seems to resolve the issue.

BhuvanTE commented 4 years ago

Having the same issue in VS2019

Please let me know what is the solution Thanks in advance

BhuvanTE commented 4 years ago

Having the same issue in VS2019

Please let me know what is the solution Thanks in advance

after installed package SpecFlow.Tools.MsBuild.Generation. working fine as able to see the tests in test exolorer

Thanks

BhuvanTE commented 4 years ago

Hi ,

"No source is available" is displaying in Test Explorer in VS2019 for Feature file tests I had gone through goggle and and did some workarounds but no luck Please help on this

srikanthse commented 4 years ago

Hello!

Is this issue being looked at ? I am facing the same on VS 2019. When I create a new feature file, it just creates a .feature file but does not come with a code behind file (.feature.cs) and these tests don't show up on the test runner as well. I already have the package SpecFlow.Tools.MsBuild.Generation installed but it still doesn't work.

In my case, I had both the generated steps and the feature file in the same folder.

Visual Studio: 2019 (latest updates installed) Specflow extension: 2019.0.42.36358 SpecFlow.Tools.MsBuild.Generation: 2.4.1 NUnit: 3.11.0

Regards, Srikanth

SabotageAndi commented 4 years ago

@srikanthse Which project format are you using? Classic or sdk-style?

JorisDeKloris commented 4 years ago

Solution for me was for the projects concerned to delete the SpecFlow.Tools.MsBuild.Generation and reinstall them again. I was upgrading specflow 2.X to 3.X, and also from VS2017 to 2019 so no idea where problem occured but that seems to solve it. Some projects have no problems, some do. I have scenarios and steps in different folders, doesn't seem to matter.

ooge0 commented 4 years ago

After updating SpecFlow packages up to v.3.1.67 had the same problems. image

I was trying to downgrade version but it's not working. Extension is up to date:

image

@JorisDeKloris solution did not help :( Uninstall all packages => rebot MVS => install again => reboot => the same result

Visual studio info below:

Microsoft Visual Studio Community 2019 Version 16.4.1 VisualStudio.16.Release/16.4.1+29609.76 Microsoft .NET Framework Version 4.7.03062 Installed Version: Community ASP.NET and Web Tools 2019 16.4.457.38025 ASP.NET and Web Tools 2019 ASP.NET Web Frameworks and Tools 2019 16.4.457.38025 Azure App Service Tools v3.0.0 16.4.457.38025 Azure App Service Tools v3.0.0 Azure Functions and Web Jobs Tools 16.4.457.38025 Azure Functions and Web Jobs Tools C# Tools 3.4.1-beta4-19607-02+52d275c4f82f329a9732b078c7f7fa0e45cd3e84 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.21016.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 2.0.87+gbb515bf382 Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. NuGet Package Manager 5.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info SQL Server Data Tools 16.0.61912.09160 Microsoft SQL Server Data Tools TypeScript Tools 16.0.11031.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.4.1-beta4-19607-02+52d275c4f82f329a9732b078c7f7fa0e45cd3e84 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 10.4 for F# 4.6 16.4.0-beta.19556.5+e7597deb7042710a7142bdccabd6f92b0840d354 Microsoft Visual F# Tools 10.4 for F# 4.6 Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Container Tools Extensions (Preview) 1.0 View, manage, and diagnose containers within Visual Studio. Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers

SabotageAndi commented 4 years ago

For me looks like the same as in https://github.com/techtalk/SpecFlow/issues/1809

Short explainer about the feature.cs files in the solution explorer: In the old csproj format (the big xml) the feature.cs files aren't displayed in the solution explorer. This is a limitation in the old project system. It works in the new sdk-style format. But that doesn't matter, because the files are compiled and the classes are in the compiled assembly. This is all done in the SpecFlow.Tools.MSBuild.Generation package.

In the above mentioned issue, the test adapter NuGet package was missing. Adding it and the scenarios were displayed in the test explorer.

ooge0 commented 4 years ago

For me looks like the same as in #1809

Short explainer about the feature.cs files in the solution explorer: In the old csproj format (the big xml) the feature.cs files aren't displayed in the solution explorer. This is a limitation in the old project system. It works in the new sdk-style format. But that doesn't matter, because the files are compiled and the classes are in the compiled assembly. This is all done in the SpecFlow.Tools.MSBuild.Generation package.

In the above mentioned issue, the test adapter NuGet package was missing. Adding it and the scenarios were displayed in the test explorer.

thanks. will check

TheDevelolper commented 4 years ago

vediankit I think i just needed to include the SpecFlow.Tools.MsBuild.Generation. That seems to resolve the issue.

This worked well for me!

KCS289 commented 4 years ago

For me looks like the same as in #1809

Short explainer about the feature.cs files in the solution explorer: In the old csproj format (the big xml) the feature.cs files aren't displayed in the solution explorer. This is a limitation in the old project system. It works in the new sdk-style format. But that doesn't matter, because the files are compiled and the classes are in the compiled assembly. This is all done in the SpecFlow.Tools.MSBuild.Generation package.

In the above mentioned issue, the test adapter NuGet package was missing. Adding it and the scenarios were displayed in the test explorer.

It doesn't work for me. still stuck at test explorer doesn't show the tests.

KCS289 commented 4 years ago

For me looks like the same as in #1809 Short explainer about the feature.cs files in the solution explorer: In the old csproj format (the big xml) the feature.cs files aren't displayed in the solution explorer. This is a limitation in the old project system. It works in the new sdk-style format. But that doesn't matter, because the files are compiled and the classes are in the compiled assembly. This is all done in the SpecFlow.Tools.MSBuild.Generation package. In the above mentioned issue, the test adapter NuGet package was missing. Adding it and the scenarios were displayed in the test explorer.

thanks. will check

I have the same problem with you. Did you manage to solve it ? Kindly share it to me. Thank you.

sup-engineer commented 4 years ago

Having the same issue in VS2019

Please let me know what is the solution Thanks in advance

after installed package SpecFlow.Tools.MsBuild.Generation. working fine as able to see the tests in test exolorer

Thanks

Had same issue with: VS 19 Specflow.Xunit 3.1.97

Installing this resolved the issue and can see my tests now

SabotageAndi commented 3 years ago

Looks like it is solved => closing issue

aivascu commented 3 years ago

In case someone else using the "classic" (legacy) project structure stumbles on this. As mentioned in the #1809 , the workaround is to include the *.feature.cs files into the project file. I overlooked that reference and it took me almost a day to find the solution.

karthikanbazhagan commented 3 years ago

Hi, I was using Specflow with xunit. And I tried many options but nothing worked. At last I casually saw a nuget package called xunit.runner.visualstudio and installed it. And it worked for me :-)

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.