尝试生成测试执行报告时,specflow失败

ngm*_*ngm 8 msbuild specflow

我有一个项目正在使用SpecFlow,NUnit和Coypu对Web应用程序进行验收测试.我在构建服务器上通过Jenkins建立了项目.Jenkins调用psake脚本在specs项目上运行msbuild,然后脚本调用nunit-console来运行specs/tests,然后我想从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 }
}
Run Code Online (Sandbox Code Playgroud)

最后一次对specflow.exe的exec调用失败,但是:

元素<UsingTask>下的元素<ParameterGroup>无法识别.C:\ Program Files(x86)\ Jenkins\jobs\TheWebApp\workspace\Web\Sites\TheWebApp.nuget \nuget.targets

一些谷歌搜索暗示可能是使用msbuild版本的问题(例如这里,这里).但是Framework "4.0"我的psake脚本中,Specs项目的目标是.NET Framework 4.0,它在构建步骤中构建得很好,所以我不确定为什么specflow似乎使用了早期版本的msbuild.或者也许是其他地方的问题?

ngm*_*ngm 30

这是我从SpecFlow Wiki得到的答案:

对于.NET 4.0项目很重要:因为specflow.exe是为.NET 3.5编译的,所以默认情况下无法加载.NET 4.0程序集.要为.NET 4.0项目生成此报告,必须使用配置文件强制specflow.exe使用.NET 4.0运行时.只需复制下面的配置并创建specflow.exe.config文件并将其放在specflow.exe旁边,您就可以创建步骤定义报告.

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup> 
        <supportedRuntime version="v4.0.30319" /> 
    </startup> 
</configuration> 
Run Code Online (Sandbox Code Playgroud)