Specflow无法检测到我的测试VS 2017

问题描述 投票:1回答:1

很久以来我一直在尝试,但是还没有成功。我创建了新的单元测试项目,并添加了以下内容:

包装:

Nunit - 3.10.0
Nunit3TestAdapter - 3.11.0
SpecFlow - 2.3.2
SpecFlow.Assist.Dynamic - 1.3.1

App.Config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="specFlow"
             type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
  </configSections>
  <specFlow>
    <unitTestProvider name="MsTest" />
  </specFlow>
</configuration>

[我也尝试使用Nunit进行上述配置。

还添加了specflow默认功能文件和步骤定义文件。但是,VS 2017仍然无法检测到我的任何测试。

总是作为输出:NUnit在...中找不到任何测试。

我已经为Visual Studio 2017安装了Specflow。

visual-studio-2017 nunit mstest specflow
1个回答
0
投票

Specflow.Tools.MSBuild.Generation版本= 2.3.2中有错误

一种解决方法是编辑.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>
© www.soinside.com 2019 - 2024. All rights reserved.