Helping Hands
Helping Hands

Reputation: 5396

Specflow could not detect my tests VS 2017

I have been trying since long but no success yet. I created fresh unit test project and added the following :

Packages :

Nunit - 3.10.0
Nunit3TestAdapter - 3.11.0
SpecFlow - 2.3.2
SpecFlow.Assist.Dynamic - 1.3.1

App.Config :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="specFlow"
             type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
  </configSections>
  <specFlow>
    <unitTestProvider name="MsTest" />
  </specFlow>
</configuration>

I tried with Nunit as well for above config.

Also added specflow default feature file and step definition file. But still VS 2017 can not detect any of my tests.

always getting as output : NUnit couldn't find any tests in ....

I have already installed Specflow for Visual Studio 2017.

Upvotes: 1

Views: 221

Answers (1)

Chui Tey
Chui Tey

Reputation: 5584

There is a bug in Specflow.Tools.MSBuild.Generation Version=2.3.2

A 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: 2

Related Questions