Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I have to include the class.feature.cs file in source control?

Using Specflow 2.1, NUnit 3.4 and Visual Studio 2015 I am fixing to submit my source code into git. When i got to Foobar.feature.cs it says it is autogenerated. I see in the csproj file that it is compiled (makes sense) and that it depends on the feature file, and that it is generated.

<ItemGroup>
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Foobar.feature.cs">
        <AutoGen>True</AutoGen>
        <DesignTime>True</DesignTime>
        <DependentUpon>Foobar.feature</DependentUpon>
    </Compile>
    <Compile Include="FoobarSteps.cs" />
</ItemGroup>
<ItemGroup>
    <None Include="App.config" />
    <None Include="packages.config" />
    <None Include="Foobar.feature">
        <Generator>SpecFlowSingleFileGenerator</Generator>
        <LastGenOutput>Foobar.feature.cs</LastGenOutput>
    </None>
</ItemGroup>

so nothing out of the ordinary there. After my code gets pushed into origin/master we would kick off a jenkins build so out of curiosity I moved the feature.cs file out, tried to build and the build failed because of the missing file. I opened the feature file, made no changes but hit save (so that the generator creates the file) and now build works again.

Is there a way around this? I would rather not have auto-generated code in source when it can be generated.

like image 463
Robert Snyder Avatar asked Jul 13 '16 20:07

Robert Snyder


1 Answers

The code-behind Files are needed, because there is the code for the different test runners to recognize the scenarios as tests.

If you do not want to check them in, you could generate them when you are building.

See http://www.specflow.org/documentation/Generate-Tests-from-MsBuild/ for an explanation how to do it.

like image 122
Andreas Willich Avatar answered Sep 21 '22 15:09

Andreas Willich