尝试生成测试执行报告时,specflow失败 [英] specflow fails when trying to generate test execution report

查看:65
本文介绍了尝试生成测试执行报告时,specflow失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用SpecFlow,NUnit和Coypu在Web应用程序上进行验收测试的项目.我已经通过Jenkins在构建服务器上构建了项目. Jenkins调用了一个psake脚本,该脚本在specs项目上运行msbuild,然后该脚本调用nunit-console来运行spec/test,然后我要从SpecFlow生成报告.

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 }
}

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

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

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

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

有点谷歌搜索暗示可能是所使用的msbuild版本存在问题(例如此处).但是我的psake脚本中有Framework "4.0",并且Specs项目的目标是.NET Framework 4.0,并且在构建步骤中构建良好,因此我不确定为什么specflow似乎正在使用早期版本的msbuild.或者也许是其他地方的问题?

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?

推荐答案

这是我的答案,来自 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旁边,就可以创建步骤定义报告.

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> 

这篇关于尝试生成测试执行报告时,specflow失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆