MaZami
MaZami

Reputation: 81

Specflow test not discovered on test explorer c#

I have researched a lot before posting the question but I could not find a solution to fix my issue.

I am trying to use selenium to do automation testing, but the issue is that my test explorer is not picking up the specflow tests for some reason.

Here is what I am using:

NuGet Packages I have installed:

I also have the Specflow for Visual Studio 2017 installed.

I have installed and Uninstalled loads of NuGet packages to try and fix this issue. Anyone able to help me please?

Upvotes: 4

Views: 6875

Answers (4)

I added the Specflow.xUnit NuGet Package and it fixed the problem. (NetCore 5)

Upvotes: 1

Chui Tey
Chui Tey

Reputation: 5574

If you are encountering the problem, and have already installed Specflow.Tools.MSBuid.Generation NuGet package in your project, and you intermittently lose your generated tests, then you should be aware that there is a bug in Specflow.Tools.MSBuild.Generation Version=2.3.2

You can upgrade to a newer version of Specflow.Tools.MSBuild.Generation or apply a workaround.

The workaround is to edit your .csproj and add a section after AfterUpdateFeatureFilesInProject.

<Target Name="AfterUpdateFeatureFilesInProject">
  <ItemGroup>
    <Compile Include="@(SpecFlowGeneratedFiles)" />
  </ItemGroup>
</Target>

<!-- Workaround Specflow 2.3 MSBuild bug. SpecFlowGeneratedFiles 
     is not set if UpdateFeatureFilesInProject is up-to-date
   causing tests not to be discovered, as they are not included in the project -->
<ItemGroup>
  <Compile Include="**/*.feature.cs" Exclude="@(SpecFlowGeneratedFiles)">
    <DependentUpon>%(Filename)</DependentUpon>
  </Compile>
</ItemGroup>

Upvotes: 1

MaZami
MaZami

Reputation: 81

After a lot of trying, I finally fixed. After deleting one of the the runners, SpecRun, I added the Specflow.Tools.MSbuild.Generation NuGet Package and it fixed the problem.

Hope it is useful for someone with the same issue!

Upvotes: 4

StevieBruce
StevieBruce

Reputation: 65

Seems to me that you could be missing the Reference to TechTalk.SpecRun.Common. Please check that this is in your solution references.

If it is Referenced, your Test Adapter cache might be corrupted. Try having a look through these steps: Troubleshooting Visual Studio Integration

Upvotes: 0

Related Questions