gpt4 book ai didi

c# - 使用 Nunit 和 Specflow 报告生成的 Cake 构建

转载 作者:行者123 更新时间:2023-11-30 20:26:53 30 4
gpt4 key购买 nike

目前在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...

Error: Error occurred when compiling build script: C:/work/dcom-test-suite/build.cake(67,21): error CS0117: 'NUnit3Result' does not contain a definition for 'ResultFormat' C:/work/dcom-test-suite/build.cake(68,21): error CS0117: 'NUnit3Result' does not contain a definition for 'Labels' C:/work/dcom-test-suite/build.cake(69,21): error CS0117: 'NUnit3Result' does not contain a definition for 'OutputFile'

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

最佳答案

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"
});
});

关于c# - 使用 Nunit 和 Specflow 报告生成的 Cake 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49400995/

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