【问题标题】:Installed Specflow.Allure and met MSB4018:"The generateFeatureFileCodeBehindTask" task failed unexpectedly安装 Specflow.Allure 并遇到 MSB4018:"The generateFeatureFileCodeBehindTask" 任务意外失败
【发布时间】:2020-09-29 08:47:07
【问题描述】:

我尝试将 allure 用于我的 specflow 测试框架。我安装了最新的 Specflow.Allure Nuget 包(3.1.0.6)和 Specflow.NUnit(3.4.8)。然后我尝试将 App.config 配置为官方网站列表。当我构建项目时,我遇到了这个问题。我不太确定发生了什么。这是我的 github repository .有人可以看看吗?

【问题讨论】:

    标签: c# specflow allure


    【解决方案1】:

    此外,Specflow 最新版本存在一些缺陷。如果我将我的 specflow NuGet 包更新到最新版本并将其与 Specflow.Allure 一起使用,则会发生 TypeInitializationException。但是如果我使用 specflow 3.3.57,TypeInitializationException 就会消失。请查看我的 Github 存储库以重现该错误。 TypeInitializationExceptionValid Specflow Nuget Package

    【讨论】:

    【解决方案2】:

    如果您展开错误消息,您可以看到完整的错误消息:

    您在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>
    

    你什么都不需要。

    1. 插件 app.config/specflow.json 中不再配置插件。我们正在输出文件夹中搜索所有以SpecFlowPlugin.dll 结尾的文件。

    2. 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>
    

    因此不再配置任何内容,因为默认值适合您。

    【讨论】:

    • 谢谢,安德烈亚斯。我已经通过删除整个应用程序解决了这个问题。配置文件。你是对的,即使 Allure 文档说配置 app.Config 文件,我们也不需要它。要将 Specflow.Allure 与 Specflow 一起使用,我们需要指定 specflow.json 文件,就像官网一样,记得复制到输出。查看 allure 文档 Specflow.Plugin.Nuget.Test 以了解我们如何使用绑定来生成 allure Specflow 报告。另一个问题是我不太明白为什么我们需要在项目中包含 specflow.json 以获得魅力。这是什么意思?
    • 您可以在 specflow.json 中配置 Allure。见github.com/allure-framework/allure-csharp#links
    • 在检查 Allure 时,我注意到他们在插件中有一些钩子,所以你必须将它作为 stepAssembly 添加到你的配置中。我调整了上面的答案。
    猜你喜欢
    • 2021-03-22
    • 2020-07-18
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 2023-01-03
    • 2011-10-06
    • 1970-01-01
    • 2020-06-30
    相关资源
    最近更新 更多