OpenCover MSBuild Integration - No results generated

时光毁灭记忆、已成空白 提交于 2020-01-11 09:21:51

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/6999279/opencover-msbuild-integration-no-results-generated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!