目前,在一个用于Selenium+SpecFlow+NUnit测试的项目中,开始使用cake Buildv0.23.0。需要创建一个SpecFlow报告,它可以使用NUnit result.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报告的地方,以显示可理解的结果。这部分我是从这个问题中取来的。当我试图执行此配置时,我在控制台中遇到了这样的错误:
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”不包含“Labels”的定义C:/work/dcom-test-suite/build.cake(69,21):错误CS0117:“nUnit3Result”不包含“OutputFile”的定义
有人能帮我解决这个问题吗?提前谢谢你。
Cake0.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"
});
});