问题描述
我试图对我的specflow测试框架使用诱惑力。我安装了最新的Specflow.Allure Nuget软件包(3.1.0.6)和Specflow.NUnit(3.4.8)。然后,我尝试将App.config配置为官方网站列表。在构建项目时,我遇到了这个问题。我不太确定发生了什么事。这是我的github repository 有人可以看看吗?
解决方法
您在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>
由于默认值适合您,因此不再进行任何配置。
,此外,Specflow最新版本也有一些缺陷。如果我将specflow NuGet软件包更新为最新版本,并将其与Specflow.Allure一起使用,则会发生TypeInitializationException。但是,如果我使用specflow 3.3.57,则TypeInitializationException将消失。请查看我的Github存储库以重现该错误。 TypeInitializationException Valid Specflow Nuget Package