使用 Nunit 和 Specflow 报告生成的 Cake 构建
Cake build with the Nunit and Specflow report generating
目前在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 报告的地方,以显示可理解的结果。这部分我摘自这个。当我尝试执行此配置时,我在控制台中收到此类错误:
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
的重大更改,尚未在您提供的 link 中更新。有关详细信息,请参阅 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"
});
});
目前在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 报告的地方,以显示可理解的结果。这部分我摘自这个
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
的重大更改,尚未在您提供的 link 中更新。有关详细信息,请参阅 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"
});
});