在 FinalBuilder 中为 NUnit 设置 NOver
已解决:查看此问题的底部以了解工作配置
我正在尝试设置 NCover 以在我的 FinalBuilder 项目中用于 .NET 4.0 C# 项目,但我的最终覆盖率输出文件不包含覆盖数据。
我正在使用:
所有工具都是截至今天的最新官方消息。
我终于设法让 FB 在 .NET 4.0 项目的 Nover 下运行我的单元测试,因此我得到了 Tests run: 184, ...
,这是正确的。
然而,NCover 的最终 Coverage.xml
文件输出几乎是空的,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<!-- saved from NCover 3.0 Export url='http://www.ncover.com/' -->
<coverage profilerVersion="3.3.2.6211" driverVersion="3.3.2" exportversion="3" viewdisplayname="" startTime="2010-04-22T08:55:33.7471316Z" measureTime="2010-04-22T08:55:35.3462915Z" projectName="" buildid="27c78ffa-c636-4002-a901-3211a0850b99" coveragenodeid="0" failed="false" satisfactorybranchthreshold="95" satisfactorycoveragethreshold="95" satisfactorycyclomaticcomplexitythreshold="20" satisfactoryfunctionthreshold="80" satisfactoryunvisitedsequencepoints="10" uiviewtype="TreeView" viewguid="C:\Dev\VS.NET\LVK.IoC\LVK.IoC.Tests\bin\Debug\Coverage.xml" viewfilterstyle="None" viewreportstyle="SequencePointCoveragePercentage" viewsortstyle="Name">
<rebasedpaths />
<filters />
<documents>
<doc id="0" excluded="false" url="None" cs="" csa="00000000-0000-0000-0000-000000000000" om="0" nid="0" />
</documents>
</coverage>
FB 日志中的输出为:
...
***************** End Program Output *****************
Execution Time: 1,5992 s
Coverage Xml: C:\Dev\VS.NET\LVK.IoC\LVK.IoC.Tests\bin\Debug\Coverage.xml
NCover Success
我对 NCover 的 FB 步骤的配置:
- NCover 什么?< /strong>:NUnit 测试覆盖率
- 命令:
C:\Program Files (x86)\NUnit 2.5.4\bin\net-2.0\nunit-console.exe
- 命令参数:
LVK.IoC.Tests.dll /noshadow /framework:4.0.30319 /process=single /nothread
- 注意:我尝试过使用和不使用
/process
和/nothread
选项
- 注意:我尝试过使用和不使用
- 工作目录 :
%FBPROJECTDIR%\LVK.IoC.Tests\bin\Debug
- 要分析的程序集列表:
%FBPROJECTDIR%\LVK.IoC.Tests\bin\Debug \LVK.IoC.dll
- 注意:我尝试只列出程序集的名称,包括带扩展名和不带扩展名的名称。
FB 步骤的文档没有帮助,因为它只列出了小句子每个属性,并且没有给出示例或故障排除提示。
由于我想将覆盖率结果提取到 NDepend 中以运行构建时分析,因此我希望该文件包含我需要的信息。
我也在使用 TestDriven,如果我右键单击解决方案文件并选择“使用 NCover 进行测试”, NCover-explorer 打开覆盖率数据,如果我要求它显示包含覆盖率文件的文件夹,其中有一个 .xml 文件,其结构与上面的文件相同,只是包含应该存在的所有数据,所以我拥有的工具当然能够实现它。
有人知道我在这里配置了什么错误吗?
已解决:以下配置终于对我有用了。它会在构建的开始结果页面上生成代码覆盖率基本统计信息,并提供包含所有内容的详细报告的链接。
由于我将单元测试项目命名为与其测试的项目相同的名称,仅带有 .Tests 后缀,因此我已将它们从代码覆盖率中排除。另外,我必须专门只包含我自己的程序集(全部以 LVK 开头),否则我会得到 TeamCity 运行程序加载的一些程序集,这会稍微影响我的覆盖率统计数据。
首先,我安装了最新的工具(截至本次编辑):
- NCover 3.4.8
- TeamCity 5.1.2
- NUnit 2.5.5
TeamCity 中构建屏幕上的配置如下:
- 目标:重建
- 配置:调试
- 平台:任何CPU
- .NET 覆盖工具:NCover (3.x)
- .NET 运行时:.NET Framework 4.0,版本:
- NCover 3 的本机路径:%system.ncover.v3.x64.path%(这是 Windows 2008 Server R2 64 位) )
其他 NCover 参数:
//ias LVK.* //eas.*测试 //eas LVK\.CodeQuality //ea LVK\.CodeQuality\.IgnoreCodeCoverageAttribute
其他 NCover 报告参数:
//或 FullCoverageReport:Html:{teamcity.report.path}
NUnit Runner:NUnit 2.5.5
- .NET 运行时平台:auto (MSIL),版本:4.0
- 从以下位置运行测试: **\bin\Debug*Tests.dll
Solved: Look at the bottom of this question for the working configuration
I am attempting to set up NCover for usage in my FinalBuilder project, for a .NET 4.0 C# project, but my final coverage output file contains no coverage data.
I am using:
All tools are the latest official as of today.
I've finally managed to coax FB into running my unit tests under NCover for the .NET 4.0 project, so I get Tests run: 184, ...
, which is correct.
However, the final Coverage.xml
file output from NCover is almost empty, and looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!-- saved from NCover 3.0 Export url='http://www.ncover.com/' -->
<coverage profilerVersion="3.3.2.6211" driverVersion="3.3.2" exportversion="3" viewdisplayname="" startTime="2010-04-22T08:55:33.7471316Z" measureTime="2010-04-22T08:55:35.3462915Z" projectName="" buildid="27c78ffa-c636-4002-a901-3211a0850b99" coveragenodeid="0" failed="false" satisfactorybranchthreshold="95" satisfactorycoveragethreshold="95" satisfactorycyclomaticcomplexitythreshold="20" satisfactoryfunctionthreshold="80" satisfactoryunvisitedsequencepoints="10" uiviewtype="TreeView" viewguid="C:\Dev\VS.NET\LVK.IoC\LVK.IoC.Tests\bin\Debug\Coverage.xml" viewfilterstyle="None" viewreportstyle="SequencePointCoveragePercentage" viewsortstyle="Name">
<rebasedpaths />
<filters />
<documents>
<doc id="0" excluded="false" url="None" cs="" csa="00000000-0000-0000-0000-000000000000" om="0" nid="0" />
</documents>
</coverage>
The output in FB log is:
...
***************** End Program Output *****************
Execution Time: 1,5992 s
Coverage Xml: C:\Dev\VS.NET\LVK.IoC\LVK.IoC.Tests\bin\Debug\Coverage.xml
NCover Success
My configuration of the FB step for NCover:
- NCover what?: NUnit test coverage
- Command:
C:\Program Files (x86)\NUnit 2.5.4\bin\net-2.0\nunit-console.exe
- Command arguments:
LVK.IoC.Tests.dll /noshadow /framework:4.0.30319 /process=single /nothread
- Note: I've tried with and without the
/process
and/nothread
options
- Note: I've tried with and without the
- Working directory:
%FBPROJECTDIR%\LVK.IoC.Tests\bin\Debug
- List of assemblies to profile:
%FBPROJECTDIR%\LVK.IoC.Tests\bin\Debug\LVK.IoC.dll
- Note: I've tried just listing the name of the assembly, both with and without the extension.
The documentation for the FB step doesn't help, as it only lists minor sentences for each property, and fails to give examples or troubleshooting hints.
Since I want to pull the coverage results into NDepend to run build-time analysis, I want that file to contain the information I need.
I am also using TestDriven, and if I right-click the solution file and select "Test with NCover", NCover-explorer opens up with coverage data, and if I ask it to show me the folder with coverage files, in there is an .xml file with the same structure as the one above, just with all the data that should be there, so the tools I have is certainly capable of producing it.
Has anyone an idea of what I've configured wrong here?
Solved: The following configuration finally worked for me. It produces a code coverage basic statistics on the start results page for a build, with a link to a detailed report with everything.
Since I name my unit test projects the same as the project it tests, only with a .Tests suffix, I've excluded those from the code coverage. Also, I had to specifically include only my own assemblies (which all start with LVK.) otherwise I would get some assemblies loaded by the TeamCity runner, which slightly impacted my coverage statistics.
First, I installed latest of the tools (as of this edit):
- NCover 3.4.8
- TeamCity 5.1.2
- NUnit 2.5.5
The configuration on the build-screen in TeamCity is then as follows:
- Targets: Rebuild
- Configuration: Debug
- Platform: Any CPU
- .NET Coverage Tool: NCover (3.x)
- .NET Runtime: .NET Framework 4.0, Version: Native
- Path to NCover 3: %system.ncover.v3.x64.path% (this is Windows 2008 Server R2 64-bit)
Additional NCover Arguments:
//ias LVK.* //eas .*Tests //eas LVK\.CodeQuality //ea LVK\.CodeQuality\.IgnoreCodeCoverageAttribute
Additional NCover Reporting Arguments:
//or FullCoverageReport:Html:{teamcity.report.path}
NUnit Runner: NUnit 2.5.5
- .NET Runtime Platform: auto (MSIL), Version: 4.0
- Run tests from: **\bin\Debug*Tests.dll
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,NCover 无法覆盖 .NET 4.0 的测试。他们宣布了 .NET 4.0 的新版本,但尚未发布。
此处查找有关该主题的信息。就我个人而言,我没有执行此任务的经验...
更新:他们发布了支持 .NET 4.0 的 NOver 3.4。也许你可以尝试一下。
As far as I know, NCover is not capable of covering tests for .NET 4.0. They announced a new version for .NET 4.0 but it is not there yet.
Find info on the subject here. Personally I have no experience with this task...
Update: They released NCover 3.4 with .NET 4.0 support. Perhaps You give it a try.
我从这个帖子中找到了您的答案:NUnit 没有运行 Visual Studio 2010 代码
在 nunit-console-x86.exe.config 文件中,在
下添加:在
下添加为我修复了它。我使用的是 TeamCity 而不是 FinalBuilder。
我也在使用 NCover 3.4。
I've found your answer from this thread: NUnit isn't running Visual Studio 2010 code
To the nunit-console-x86.exe.config file, under
<configuration>
add:Under
<runtime>
addFixed it for me. I'm using TeamCity not FinalBuilder though.
I'm also using NCover 3.4.