2
votes

Currently in a project for Selenium+SpecFlow+Nunit tests started to use cake build v0.23.0. Need to create a SpecFlow report, which can be generated, using NUnit result .xml file. Build will be executed on the TeamCity. Here are my steps in build cake:

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

First part (which is commented) - this is current working step for executing tests in cake configuration. Second - this is where I am trying to create SpecFlow report, to show understandable results. This part I took from this question. When I am trying to execute this configuration, I am getting this kind of error in console:

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'

Can anyone help me with this issue? Thanks in advance.

1

1 Answers

4
votes

There was a breaking change introduced in Cake 0.22.0 with regards to NUnit3Settings which haven't been updated in the link you provided. See https://github.com/cake-build/cake/pull/1666 for more info.

Your code should now look something like this:

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