在某些环境中,dotCover和xUnit无法收集覆盖率统计信息 [英] dotCover and xUnit not gathering coverage statistics in some environments

查看:165
本文介绍了在某些环境中,dotCover和xUnit无法收集覆盖率统计信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用dotCover 2.7和xUnit.net 1.9.2.

We're using dotCover 2.7 and xUnit.net 1.9.2.

在我的计算机(Windows 7)和同事的计算机(Windows 8)上,我们可以针对使用xUnit.net的一个单元测试程序集从命令行运行dotCover并获取正确的覆盖率报告.

On my machine (Windows 7) and a co-worker's machine (Windows 8) we can run dotCover from the command line against one of our unit test assemblies that uses xUnit.net and get correct coverage reporting.

在我们的构建机器(Windows Server 2008 R2 Standard)上,当我们运行相同的东西时,dotCover报告的唯一代码覆盖率就是单元测试程序集本身.

On our build machine (Windows Server 2008 R2 Standard) when we run the same thing the only code coverage that dotCover reports is the unit test assembly itself.

我们正在使用MSBuild任务运行xUnit.net.这是.msbuild文件中的相关内容.

We're running xUnit.net using the MSBuild task. Here's the relevant pieces from the .msbuild file.

<UsingTask TaskName="Xunit.Runner.MSBuild.xunit" AssemblyFile="$(PackagesDir)xunit.$(XunitVersion)\lib\net20\xunit.runner.msbuild.dll" />

<Target Name="XunitTests">
    <xunit Assembly="$(TrunkDir)src.UnitTests\Ipseity.Server.Events.UnitTests\bin\Debug\Ipseity.Server.Events.UnitTests.dll" />
</Target>

我们正在使用以下命令(在每个环境中使用相同的命令)从命令行运行dotCover.

We're running dotCover from the command line using the following command (same command in each environment).

"c:\ Program Files(x86)\ JetBrains \ dotCover \ v2.7 \ Bin \ dotCover.exe"分析/TargetExecutable="c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe "/TargetArguments ="/t:XunitTests ipseity.msbuild"/TargetWorkingDir = c:\ tfs \ SI \ ipseity \ trunk \ build/Output=c:\temp\coverage.xml

"c:\Program Files (x86)\JetBrains\dotCover\v2.7\Bin\dotCover.exe" analyse /TargetExecutable="c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" /TargetArguments="/t:XunitTests ipseity.msbuild" /TargetWorkingDir=c:\tfs\SI\ipseity\trunk\build /Output=c:\temp\coverage.xml

在Windows 7和Windows 8计算机上,coverage.xml文件包含以下内容.

On the Windows 7 and Windows 8 machines the coverage.xml file contains the following.

<Root CoveredStatements="1977" TotalStatements="7867" CoveragePercent="25" ReportType="Xml" DotCoverVersion="2.7.2.176">
    <Assembly Name="Ipseity.Server.Common" CoveredStatements="4" TotalStatements="339" CoveragePercent="1">
        ...
    </Assembly>
    <Assembly Name="Ipseity.Server.Events" CoveredStatements="691" TotalStatements="798" CoveragePercent="87">
        ...
    </Assembly>
    <Assembly Name="Ipseity.Server.Events.UnitTests" CoveredStatements="1240" TotalStatements="1251" CoveragePercent="99">
        ...
    </Assembly>
    <Assembly Name="ipseity.Server.MessageProcessing" CoveredStatements="42" TotalStatements="5479" CoveragePercent="1">
        ...
    </Assembly>
</Root>

但是,在构建服务器(Windows Server 2008 R2 Standard)上,我们仅在覆盖率报告中显示了单元测试程序集.

However on the build server (Windows Server 2008 R2 Standard) we only get the unit test assembly showing up in the coverage report.

<Root CoveredStatements="1033" TotalStatements="1039" CoveragePercent="99" ReportType="Xml" DotCoverVersion="2.7.2.176">
    <Assembly Name="Ipseity.Server.Events.UnitTests" CoveredStatements="1033" TotalStatements="1039" CoveragePercent="99">
        ...
    </Assembly>
</Root>

在这一点上,我们对为什么在构建服务器上获得的结果与在开发箱上获得不同的结果感到困惑,因此,我们希望找到其他任何建议.

At this point we're baffled as to why we get different results on the build server than on our dev boxes so any suggestions as to what else to look for would be appreciated.

推荐答案

在一位DotCover开发人员的帮助下,我们终于能够找出问题所在.

With the help of one of the DotCover developers we were finally able to figure out the problem.

DotCover要求分析期间PDB文件可用.默认情况下,MSBuild <xunit...>任务影子将程序集复制到另一个文件夹中以运行测试.显然,这不会复制PDB文件,仅复制程序集.

DotCover requires that the PDB files be available during analysis. By default the MSBuild <xunit...> task shadow copies the assemblies into another folder to run the tests. This apparently does not copy the PDB files, only the assemblies.

因此,要解决此问题,我们只需要关闭卷影复制即可.

So to fix the problem we simply had to turn shadow copying off.

原始MSBuild任务

<xunit Assembly="$(TrunkDir)\Ipseity.Server.Events.UnitTests.dll" />

已修复MSBuild任务

<xunit Assembly="$(TrunkDir)\Ipseity.Server.Events.UnitTests.dll" ShadowCopy="False" />

这篇关于在某些环境中,dotCover和xUnit无法收集覆盖率统计信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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