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

标签 msbuild specflow

我有一个项目,正在使用 SpecFlow、NUnit 和 Coypu 对 Web 应用程序进行验收测试。我已经通过 Jenkins 在构建服务器上构建了项目。 Jenkins 调用一个 psake 脚本,该脚本在规范项目上运行 msbuild,然后该脚本调用 nunit-console 来运行规范/测试,然后我想从 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 }
}

最后一次对specflow.exe的exec调用失败了,并显示:

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

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

最佳答案

这就是我的答案,来自 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> 

关于msbuild - 尝试生成测试执行报告时specflow失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11363202/

相关文章:

c# - 在编译输出中添加程序集绑定(bind) (app.config)

azure - 未为 "CSPack"任务指定所需参数 "ServiceDefinitionFile"的值

tfs - 如何将 TFS 变量传递给项目的 MSBuild 任务

deployment - TFS Web Deploy 不通过构建执行而是在本地执行?

visual-studio-2013 - 如何格式化specflow .feature 文件

c# - 错误构建 VSTS : ## [error] Error: Unable to locate the 'nuget'

c# - 范围报告不生成报告

c# - Visual Studio 中的 "Treat all warnings as errors except..."

mvvm - 如何使用 MVVM 通过 WPF 应用程序实现 Specflow

windows - 有没有办法在Gradle脚本中为Windows目录路径使用通配符?