0
votes

I have three test projects in a solution. In one I create my feature files with scenarios and I add them as links in the other two (so the scenarios are completely identical but with different step implementation within the three projects). I use Visual Studio 2019 and Specflow 3 with MsTest as test runner. The packages that I've included are:

  <package id="Gherkin" version="6.0.0" targetFramework="net472" />
  <package id="SpecFlow" version="3.0.225" targetFramework="net472" />
  <package id="SpecFlow.MsTest" version="3.0.225" targetFramework="net472" />
  <package id="SpecFlow.Tools.MsBuild.Generation" version="3.0.225" targetFramework="net472" />

When I build the solution I only see the tests from the first project in Test Explorer. Tests for the project with linked feature files are not generated. Is this even possible with Specflow 3?

1
What do you mean by "add them as links in the other two [projects]"? I've never done something like this before.Greg Burghardt
In VS you can add existing item to a project and there is an option "Add as link".Petko Zhekov
That's interesting. I didn't know about that feature. I'll have to keep that in mind, since we are using SpecFlow extensively. We don't have overlapping features yet, but very good to know.Greg Burghardt

1 Answers

2
votes

No, adding feature files as links is not supported.

We in the SpecFlow team came to the conclusion that we will probably never get all cases covered how linked files could be used in a projects. There are questions like where to put the generated code-behind files and other, that are always specific to the project.

Our suggestion as an alternative to linked files is to copy the feature files in a before build target. We do this our self in SpecFlow to get feature files from Cucumber. It is here: https://github.com/techtalk/SpecFlow/blob/master/Tests/TechTalk.SpecFlow.Specs/TechTalk.SpecFlow.Specs.csproj#L83


Full disclosure: I am one of the maintainers of SpecFlow