在测试资源管理器 C# 上未发现 Specflow 测试
Specflow test not discovered on test explorer c#
我在发布问题之前进行了很多研究,但找不到解决问题的方法。
我正在尝试使用 selenium 进行自动化测试,但问题是我的测试资源管理器出于某种原因没有选择 specflow 测试。
这是我正在使用的:
- c# .net 核心项目
- Specflow
- Xunit
- 硒driver
- 硒 Chrome Driver
我安装的 NuGet 包:
- Selenium.Support
- Selenium.WebDriver
- Selenium.WebDriver.ChromeDriver
- Specflow
- Specflow.NetCore
- Specflow.xUnit
- SpecRun.Runner
- xunit
- xunit.core
- xunit.runner.visualstudio
我还安装了 Visual Studio 2017 的 Specflow。
我已经安装和卸载了大量的 NuGet 包来尝试解决这个问题。有人能帮帮我吗?
在我看来,您可能遗漏了对 TechTalk.SpecRun.Common 的引用。请检查这是否在您的解决方案参考中。
如果它被引用,您的测试适配器缓存可能已损坏。尝试通过以下步骤查看:
Troubleshooting Visual Studio Integration
经过多次尝试,我终于修好了。删除其中一个运行器 SpecRun 后,我添加了 Specflow.Tools.MSbuild.Generation NuGet 包,它解决了问题。
希望对遇到同样问题的人有用!
如果您遇到问题,并且已经在您的项目中安装了 Specflow.Tools.MSBuid.Generation
NuGet 包,并且您
间歇性地丢失你生成的测试,那么你应该意识到
Specflow.Tools.MSBuild.Generation
Version=2.3.2
中有错误
您可以升级到更新版本 Specflow.Tools.MSBuild.Generation
或应用解决方法。
解决方法是编辑您的 .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>
我添加了 Specflow.xUnit NuGet 包,它解决了这个问题。 (NetCore 5)
我在发布问题之前进行了很多研究,但找不到解决问题的方法。
我正在尝试使用 selenium 进行自动化测试,但问题是我的测试资源管理器出于某种原因没有选择 specflow 测试。
这是我正在使用的:
- c# .net 核心项目
- Specflow
- Xunit
- 硒driver
- 硒 Chrome Driver
我安装的 NuGet 包:
- Selenium.Support
- Selenium.WebDriver
- Selenium.WebDriver.ChromeDriver
- Specflow
- Specflow.NetCore
- Specflow.xUnit
- SpecRun.Runner
- xunit
- xunit.core
- xunit.runner.visualstudio
我还安装了 Visual Studio 2017 的 Specflow。
我已经安装和卸载了大量的 NuGet 包来尝试解决这个问题。有人能帮帮我吗?
在我看来,您可能遗漏了对 TechTalk.SpecRun.Common 的引用。请检查这是否在您的解决方案参考中。
如果它被引用,您的测试适配器缓存可能已损坏。尝试通过以下步骤查看: Troubleshooting Visual Studio Integration
经过多次尝试,我终于修好了。删除其中一个运行器 SpecRun 后,我添加了 Specflow.Tools.MSbuild.Generation NuGet 包,它解决了问题。
希望对遇到同样问题的人有用!
如果您遇到问题,并且已经在您的项目中安装了 Specflow.Tools.MSBuid.Generation
NuGet 包,并且您
间歇性地丢失你生成的测试,那么你应该意识到
Specflow.Tools.MSBuild.Generation
Version=2.3.2
您可以升级到更新版本 Specflow.Tools.MSBuild.Generation 或应用解决方法。
解决方法是编辑您的 .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>
我添加了 Specflow.xUnit NuGet 包,它解决了这个问题。 (NetCore 5)