测试资源管理器 visual studio 2015 未发现 specflow 测试

Test explorer visual studio 2015 not discovering specflow tests

不确定这是 visual studio 错误还是我遗漏了明显的问题,但这有点偶然。

有时 Visual Studio 发现测试,大多数时候我只能看到选取框进度条,什么也看不到。

关于原因有什么想法吗?

已编辑

这是怎么回事:

有时测试不显示 大多数时间测试显示,但是当 building/rebuilding 解决方案比选取框进度条进入无限循环并且 运行 选定测试和调试选定测试都被禁用,因此不能 运行 test.The 输出 windows 什么都不显示。

查看 Output Pane/Test 输出是否有一些消息表明测试不可见的原因。
SpecFlow 生成具有属性的正常 MSTest 测试用例。所以测试浏览器应该每次都能找到它们,而不需要做任何额外的工作。

Specflow.Tools.MSBuild.Generation 版本=2.3.2.

中存在错误

它的简短摘要如下:Specflow 找到 .feature 个文件 并且如果任何相应的 .feature.cs 文件丢失或 过时了,它将生成它们并将它们添加到文件列表中 称为 SpecFlowGeneratedFiles.csproj 包含一个部分 将 SpecFlowGeneratedFiles 编译到程序集中。如果文件 不包括在内,那么程序集中没有测试,因此 没有发现测试。

如果所有 .feature.cs 文件都已经存在并且 最新的, SpecFlowGeneratedFiles 没有设置,你得到 测试神秘消失的令人气愤的情况。 您可以通过删除生成的任何一个 .feature.cs 来验证此错误 文件并重新构建。

解决方法是编辑您的 .csproj 并在 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>