【发布时间】:2020-09-29 08:47:07
【问题描述】:
我尝试将 allure 用于我的 specflow 测试框架。我安装了最新的 Specflow.Allure Nuget 包(3.1.0.6)和 Specflow.NUnit(3.4.8)。然后我尝试将 App.config 配置为官方网站列表。当我构建项目时,我遇到了这个问题。我不太确定发生了什么。这是我的 github repository .有人可以看看吗?
【问题讨论】:
我尝试将 allure 用于我的 specflow 测试框架。我安装了最新的 Specflow.Allure Nuget 包(3.1.0.6)和 Specflow.NUnit(3.4.8)。然后我尝试将 App.config 配置为官方网站列表。当我构建项目时,我遇到了这个问题。我不太确定发生了什么。这是我的 github repository .有人可以看看吗?
【问题讨论】:
此外,Specflow 最新版本存在一些缺陷。如果我将我的 specflow NuGet 包更新到最新版本并将其与 Specflow.Allure 一起使用,则会发生 TypeInitializationException。但是如果我使用 specflow 3.3.57,TypeInitializationException 就会消失。请查看我的 Github 存储库以重现该错误。 TypeInitializationExceptionValid Specflow Nuget Package
【讨论】:
您在app.config 中的配置对于 SpecFlow3 不正确。
这是您当前的 app.config 内容:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
</configSections>
<specFlow>
<plugins>
<add name="SpecFlow.Allure" type="Runtime" />
<add name="SpecFlow.NUnit" />
</plugins>
<stepAssemblies>
<stepAssembly assembly="SpecFlow.Allure.SpecFlowPlugin" />
</stepAssemblies>
For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config
use unit test provider SpecRun+NUnit or SpecRun+MsTest for being able to execute the tests with SpecRun and another provider
<unitTestProvider name="SpecFlow.NUnit" />
</specFlow>
</configuration>
你什么都不需要。
插件
app.config/specflow.json 中不再配置插件。我们正在输出文件夹中搜索所有以SpecFlowPlugin.dll 结尾的文件。
unitTestProvider SpecFlow 3 也没有此选项。现在使用运行时插件进行配置。
app.config 的结果内容是:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
</configSections>
<specFlow>
<stepAssemblies>
<stepAssembly assembly="SpecFlow.Allure.SpecFlowPlugin" />
</stepAssemblies>
</specFlow>
</configuration>
因此不再配置任何内容,因为默认值适合您。
【讨论】: