Search code examples
specflowcakebuild

Generating SpecFlow Reports with the CakeBuild Specflow plugin possible?


Is it possible to generate SpecFlow Reports with the CakeBuild Specflow plugin (CakeBuild SpecFlow) ?

enter image description here


Solution

  • Yes it's possible to create Test Execution report with Cake build. Here's a quick example using NUnit3 as test runner (other supported runners are MSTest, XUnit and NUnit2).

    #tool "nuget:?package=NUnit.ConsoleRunner"
    #tool "nuget:?package=SpecFlow"
    
    var target = Argument("target", "Default");
    
    Task("Default")
        .Does(() =>
    {
        SpecFlowTestExecutionReport(tool => {
            tool.NUnit3("/path/to/your/tests.dll",
                new NUnit3Settings {
                    Results = "/path/to/testresults.xml",
                    ResultFormat = "nunit2",
                    Labels = NUnit3Labels.All,
                    OutputFile = "/path/to/testoutput.txt"
                });
            }, "/path/to/your/test/project.csproj",
            new SpecFlowTestExecutionReportSettings {
                Out = "/path/to/specflow/execution/report.html",
                XsltFile = "/path/to/optional/transform/file.xslt"
            });
    });
    
    RunTarget(target);
    

    But as Andreas Willich answered, the example output you posted is a SpecFlow+Runner report. Honestly I can't say if the SpecFlow aliases are compatible with that runner. It's only tested with the default SpecFlow runner.