【问题标题】:Cake build with the Nunit and Specflow report generating使用 Nunit 和 Specflow 报告生成蛋糕构建
【发布时间】:2018-03-22 18:58:04
【问题描述】:

目前在 Selenium+SpecFlow+Nunit 测试项目中开始使用 cake build v0.23.0。需要创建一个 SpecFlow 报告,可以使用 NUnit 结果 .xml 文件生成该报告。构建将在 TeamCity 上执行。以下是我制作蛋糕的步骤:

/*Task("RunTests")
.IsDependentOn("Build")
.Does(() => {
    NUnit3("./SampleProject/bin/Release/SampleProject.dll", new NUnit3Settings {
                NoResults = true,
                        Where = "cat == PricingAppTests",
                        Process = NUnit3ProcessOption.InProcess
            });


});*/

Task("RunTests")
    .IsDependentOn("Build")
.Does(() => {
    SpecFlowTestExecutionReport(tool => {
    tool.NUnit3("./SampleProject/bin/Release/SampleProject.dll",
        new NUnit3Settings {
            Results = "testresults.xml",
            Format = "nunit2",
            Labels = NUnit3Labels.All,
            OutputFile = "testoutput.txt"
        });
    }, project,
    new SpecFlowTestExecutionReportSettings {
        Out = "report.html"
    });
});

第一部分(已注释) - 这是在蛋糕配置中执行测试的当前工作步骤。 第二 - 这是我试图创建 SpecFlow 报告的地方,以显示可理解的结果。这部分我取自question。当我尝试执行此配置时,我在控制台中收到这种错误:

Compiling build script...

错误:编译构建脚本时出错: C:/work/dcom-test-suite/build.cake(67,21): 错误 CS0117: “NUnit3Result”不包含“ResultFormat”的定义 C:/work/dcom-test-suite/build.cake(68,21):错误 CS0117:“NUnit3Result”不包含“标签”的定义 C:/work/dcom-test-suite/build.cake(69,21): 错误 CS0117: 'NUnit3Result' 不包含 'OutputFile' 的定义

谁能帮我解决这个问题? 提前致谢。

【问题讨论】:

    标签: c# report specflow nunit-3.0 cakebuild


    【解决方案1】:

    Cake 0.22.0 中引入了与NUnit3Settings 相关的重大更改,尚未在您提供的链接中更新。请参阅https://github.com/cake-build/cake/pull/1666 了解更多信息。

    您的代码现在应该如下所示:

    Task("RunTests")
        .IsDependentOn("Build")
        .Does(() =>
    {
        SpecFlowTestExecutionReport(tool => {
        tool.NUnit3("./SampleProject/bin/Release/SampleProject.dll",
            new NUnit3Settings {
                Results = new List<NUnit3Result> {
                    new NUnit3Result {
                        FileName = "testresults.xml",
                        Format = "nunit2"
                    }
                },
                Labels = NUnit3Labels.All,
                OutputFile = "testoutput.txt"
            });
        }, project,
        new SpecFlowTestExecutionReportSettings {
            Out = "report.html"
        });
    });
    

    【讨论】:

    • 添加此任务时,并添加行以指定测试: new NUnit3Settings { NoResults = false, Where = "cat == PricingAppTests", Process = NUnit3ProcessOption.InProcess, Results = new List ,在 cosole 中出现错误,在测试执行中:未知结果格式:nunit2 NUnit3:无效参数(退出代码 -1)。
    • 现在,当我尝试执行时,使用您的任务,正在编译构建蛋糕,但是在测试运行的步骤中,我收到了这种错误:Unknown result format: nunit2 NUnit3: Invalid argument (exit code -1).。另外,如何指定需要运行哪种测试(类别)?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    • 2022-11-17
    • 1970-01-01
    相关资源
    最近更新 更多