Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

specflow fails when trying to generate test execution report

I've got a project that's using SpecFlow, NUnit and Coypu to do acceptance tests on a web application. I've got the project building OK via Jenkins on a build server. Jenkins calls a psake script which runs msbuild on the specs project, then the script calls nunit-console to run the specs/tests, and then I want to generate a report from SpecFlow.

Framework "4.0"

task Default -depends RunSpecs

task BuildSpecs {
    $env:EnableNuGetPackageRestore = "true"
    msbuild /t:Rebuild ReturnsPortal.Specs.csproj
}

task RunSpecs -depends BuildSpecs {
    exec { & "C:\path\to\NUnit 2.5.9\bin\net-2.0\nunit-console-x86.exe" /labels /out=TestResult.txt /xml=TestResult.xml .\bin\Debug\TheWebApp.Specs.dll }
    exec { & "C:\path\to\SpecFlow\1.8.1\specflow.exe" nunitexecutionreport TheWebApp.Specs.csproj /out:SpecResult.html }
}

That last exec call to specflow.exe fails though, with:

The element <ParameterGroup> beneath element <UsingTask> is unrecognized. C:\Program Files (x86)\Jenkins\jobs\TheWebApp\workspace\Web\Sites\TheWebApp.nuget\nuget.targets

A bit of googling hints that maybe it's a problem with the msbuild version being used (e.g. here, here). But I have Framework "4.0" in my psake script, and the Specs project is targeting .NET Framework 4.0, and it builds fine in the build step, so I'm not sure why specflow seems to be using an earlier version of msbuild. Or is maybe the problem somewhere else?

like image 747
ngm Avatar asked Jul 06 '12 13:07

ngm


People also ask

How do you skip the SpecFlow test?

Just like with normal unit tests, you can also ignore SpecFlow tests. To do so, tag the feature or scenario with the @ignore tag.

What is SpecRun SpecFlow?

SpecFlow+ Runner (formerly “SpecRun”) is a dedicated test execution framework for SpecFlow. SpecFlow+ Runner integrates more tightly with Visual Studio's testing infrastructure and Team Foundation Server (TFS) Build.


1 Answers

This was the answer for me, from the SpecFlow Wiki:

Important for .NET 4.0 projects: Because specflow.exe is compiled for .NET 3.5, it cannot load .NET 4.0 assemblies by default. To generate this report for .NET 4.0 projects, you have to force specflow.exe to use the .NET 4.0 runtime by using the config file. Just copy the config below and create a specflow.exe.config file and put it next to your specflow.exe and you will be able to create the step definition report.

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup> 
        <supportedRuntime version="v4.0.30319" /> 
    </startup> 
</configuration> 
like image 130
ngm Avatar answered Oct 15 '22 22:10

ngm