OpenCover MSBuild 集成 - 未生成结果

发布于 2024-11-29 02:31:41 字数 1212 浏览 3 评论 0 原文

让 OpenCover 在我的机器上工作后,下一步是让它与构建服务器一起工作。

我一直在尝试将 OpenCover 与 Bamboo Build Server 上的 MSBuild 集成。我已按如下方式修改 Build.proj 以在构建解决方案后运行 OpenCover:

<Target Name="TestAndCodeCoverage" DependsOnTargets="Build" >
    <Message Text="Executing Unit Tests and running OpenCover to check code coverage..." />
    <MakeDir Directories="Coverage" />
    <Exec Command='"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -target:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" -targetargs:/testcontainer:"TestProject\bin\Release\TestProject.dll" -filter:+[*]* -output:Coverage\CodeCoverageResults.xml -register:user -mergebyhash' />
</Target>

在解决方案根目录(这是构建期间的工作目录)中创建“Coverage”目录。测试已运行并且全部通过,但是在构建日志中显示 Committing.... (将在命令行中显示的内容)后,不会生成任何结果,并且构建将继续进行下一个任务(使用 ReportGenerator 创建报告 - 由于未创建 CodeCoverageResults.xml,因此失败)。

当在构建机器上的命令行中运行相同的命令时,一切都会按预期工作,并且可以由 ReportGenerator 生成报告。

还有其他人遇到同样的问题吗?我是否需要像 这个 PartCover 示例?

After getting OpenCover to work on my machine, the next step is getting it to work with the build server.

I've been trying to integrate OpenCover with MSBuild on a Bamboo Build Server. I have modified Build.proj as follows to run OpenCover after building the solution:

<Target Name="TestAndCodeCoverage" DependsOnTargets="Build" >
    <Message Text="Executing Unit Tests and running OpenCover to check code coverage..." />
    <MakeDir Directories="Coverage" />
    <Exec Command='"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -target:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" -targetargs:/testcontainer:"TestProject\bin\Release\TestProject.dll" -filter:+[*]* -output:Coverage\CodeCoverageResults.xml -register:user -mergebyhash' />
</Target>

The "Coverage" directory is created in the solution root directory (which is the working directory during the build). The tests are run and all pass, but after Committing.... is displayed in the Build log (what would be displayed in the command line), no results are generated and the Build moves on to the next task (creating a report with ReportGenerator - this fails as CodeCoverageResults.xml was not created).

When running the same command in the command line on the build machine everything works as expected, and a report can be generated by ReportGenerator.

Has anyone else had the same problem? Do I need to register equivalent dlls like in this PartCover example?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

本宫微胖 2024-12-06 02:31:41

由于构建服务器是一项服务,所以我只会使用 -register 开关,但是如果在构建服务器上,我总是会说你应该使用 regsvr32 注册 32 位和 64 位分析器一次,然后删除 -register 开关,即无需每次都注册和注销分析器。

-register[:user] 开关适用于人们(比如我自己)喜欢在有限权限下工作的场景。

As the build server is a service then I would use the -register switch only, however if on a build server I would always say you should register both the 32 and 64 bit profilers, once, using regsvr32 and then drop the -register switch i.e. There is no need to register and unregister the profiler each time.

The -register[:user] switch is for those scenarios where people (like myself) like to work under limited permissions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文