gpt4 book ai didi

xunit.net - 如何让 SpecFlow 使用 xUnit.net 作为测试运行器

转载 作者:行者123 更新时间:2023-12-04 16:25:13 31 4
gpt4 key购买 nike

我正在尝试使用 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 元素。

关于xunit.net - 如何让 SpecFlow 使用 xUnit.net 作为测试运行器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2722877/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com