我正在尝试使用 xUnit.net 作为 SpecFlow 的测试运行器。来自官方下载区的 SpecFlow 1.2 二进制文件不包含 xUnit.net 提供程序,但 GitHub 上的主分支有一个,所以我从中构建了 SpecFlow.Core.dll。我正在使用 xUnit.net 1.5。
但是,当我在我的规范项目的 app.config 中更改 unitTestProvider 名称时,我收到一个空引用自定义工具错误,并且生成的 .feature.cs 文件是单行:
Object reference not set to an instance of an object.
有没有人成功地让 SpecFlow 与 xUnit.net 一起工作?如果是这样,如何?
请您参考如下方法:
我刚刚遇到了同样的问题并找到了答案。只需使用 SpecFlow 的最新版本,我使用的是 1.3.5.2。
然后你所要做的就是添加对 xUnit.dll 的引用,并使用以下配置为你的 Specs 项目创建一个 App.config 文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
</configSections>
<specFlow>
<language feature="en-US" />
<unitTestProvider name="xUnit" />
<runtime detectAmbiguousMatches="true" stopAtFirstError="false"
missingOrPendingStepsOutcome="Inconclusive" />
<trace traceSuccessfulSteps="true" traceTimings="false"
minTracedDuration="0:0:0.1" />
</specFlow>
</configuration>
在这里起作用的部分是 unitTestProvider 元素。




