Separating Gherkin feature files from generated *.feature.cs files

364 views
Skip to first unread message

Graham Davison

unread,
May 22, 2017, 2:15:15 AM5/22/17
to SpecFlow
Hi all,

Is it possible to separate the Gherkin feature files from the generated *.feature.cs files?

What I'd like to do is have a set of shared Gherkin files that can be used for testing ports of a project to various languages, such as .Net and Go. They would be added using git submodules.

I can add the gherkin files to VisualStudio as links, but then the *.feature.cs files are generated in the submodule directory as well.

    <None Include="..\shared_specs\features\Feature1.feature">
      <Link>Feature1.feature</Link>
      <Generator>SpecFlowSingleFileGenerator</Generator>
    </None>

This references the file properly, but the Feature1.feature.cs file is also generated in ..\shared_specs\features\, while I want it in .\

I've tried

    <Compile Include="Feature1.feature.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Feature1.feature</DependentUpon>
    </Compile>

but VS doesn't recognize this as actually depending on Feature1.feature.

Has anyone tried something similar to this?

Thanks,
Graham

Andreas Willich

unread,
May 22, 2017, 2:30:28 AM5/22/17
to SpecFlow

Hi Graham

I think your requirements are solvable with the MSBuild integration (http://specflow.org/documentation/Generate-Tests-from-MsBuild/).

In the last snippet, it is moving the *.cs files to a folder of your choosing.

Additional benefit is, you do not have to check in the files anymore.

I hope I could help.

Best regards
Andreas


--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sean MacKinnon

unread,
Feb 12, 2019, 10:15:13 AM2/12/19
to SpecFlow
Any luck with this? I notice the documentation Andreas referenced regarding using the AfterUpdateFeatureFilesInProject target has been removed from that page. Is it no longer supported in the latest versions of SpecFlow?

I've tried setting the LastGenOutput path to where I want the files to be generated but haven't had any success.

Andreas Willich

unread,
Feb 12, 2019, 4:34:00 PM2/12/19
to spec...@googlegroups.com
AfterUpdateFeatureFilesInProject is still working.
We only rewrote the documentation. It's still there in the "Classic Project" example.

LastGenOutput had never any influence on the generation. This is something set by VisualStudio and not by us.

We have also posted a blog post 2 weeks ago about MSBuild generation: https://specflow.org/2019/generating-code-behind-files-using-msbuild/
Have a look at our now updated best practices. We don't recommend anymore to move the generated files into a different folder.

On Tue, Feb 12, 2019 at 4:15 PM Sean MacKinnon <stmac...@gmail.com> wrote:
Any luck with this? I notice the documentation Andreas referenced regarding using the AfterUpdateFeatureFilesInProject target has been removed from that page. Is it no longer supported in the latest versions of SpecFlow?

I've tried setting the LastGenOutput path to where I want the files to be generated but haven't had any success.

--

Sean MacKinnon

unread,
Feb 13, 2019, 7:39:33 AM2/13/19
to spec...@googlegroups.com
Ah k, thanks for the response. Hadn't been using the MSBuild generator and we were using linked feature files as well. Sounds like it might not be possible, but will try a few options to see whats possible.

Fionna O'Sullivan

unread,
Feb 13, 2019, 7:48:17 AM2/13/19
to spec...@googlegroups.com
Thanks for this -- I had just started looking into how to do this and get the .feature.cs files out of version control, so it was a very timely mail!
--

Bad habits are like a comfortable bed, easy to get into, but hard to get out of.
~Anonymous
Reply all
Reply to author
Forward
0 new messages