我是否必须在源代码管理中包含 class.feature.cs 文件?

Rob*_*der 7 c# git msbuild specflow jenkins

使用 Specflow 2.1、NUnit 3.4 和 Visual Studio 2015,我正在修复将我的源代码提交到 git。当我到达Foobar.feature.cs它时说它是自动生成的。我在 csproj 文件中看到它被编译(有意义)并且它取决于功能文件,并且它是生成的。

<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>
Run Code Online (Sandbox Code Playgroud)

所以没有什么不寻常的地方。在我的代码被推入 origin/master 后,我们将启动 jenkins 构建,所以出于好奇,我将 feature.cs 文件移出,尝试构建,但由于缺少文件,构建失败。我打开了功能文件,没有做任何更改,但点击保存(以便生成器创建文件),现在构建再次工作。

有没有解决的办法?当可以生成时,我宁愿不在源代码中自动生成代码。

And*_*ich 7

需要代码隐藏文件,因为不同的测试运行器有代码来将场景识别为测试。

如果您不想签入它们,您可以在构建时生成它们。

有关如何执行此操作的说明,请参阅http://www.specflow.org/documentation/Generate-Tests-from-MsBuild/