【问题标题】:Gallio with NCover shows 0% code coverage in Sonar UI带有 NCover 的 Gallio 在 Sonar UI 中显示 0% 的代码覆盖率
【发布时间】:2012-11-20 04:20:00
【问题描述】:

我正在使用 sonar-runner 在 Gallio 插件的帮助下对我的 C# 代码运行测试和代码覆盖。测试运行良好,但我无法在声纳 Web UI 上看到任何代码覆盖率。

我的声纳设置如下:

sonar-project.properties 仅提及相关位 sonar.gallio.coverage.tool = NCover sonar.NCover.installDirectory = C:/Program Files/NCover sonar.donet.visualstudio.testProjectPattern = .Test sonar.dotnet.buildConfigurations = "发布|x86"

知道缺少什么吗?

sonar.projectKey=XXX:XXX
sonar.projectVersion=trunk
sonar.projectName=XXX
sources=.
sonar.language=cs  
sonar.dotnet.visualstudio.solution.file=Project.sln
sonar.dotnet.excludeGeneratedCode=false
sonar.dotnet.4.0.sdk.directory=C:/WIndows/Microsoft.NET/Framework/v4.0.30319
sonar.dotnet.version=4.0 
# Gallio
sonar.gallio.mode=
sonar.gallio.coverage.tool=NCover
sonar.gallio.runner=IsolatedAppDomain
sonar.NCover.installDirectory=c:/Program Files/NCover
sonar.gallio.installDirectory=C:/Program Files/Gallio
sonar.dotnet.test.assemblies=$(SolutionDir)/../**/bin/**/*.Tests.Unit.dll
# FXCop
sonar.fxcop.mode=   
#StyleCop
sonar.stylecop.mode= 
#NDeps
sonar.ndeps.mode=skip

sonar-runner.properties

【问题讨论】:

    标签: nunit sonarqube gallio ncover


    【解决方案1】:

    你说

    sonar.dotnet.buildConfigurations = "发布|x86"

    如果是这样,您的构建可能不会生成 .pdb 文件,这是确定二进制文件和源文件之间的映射所必需的。

    如果您在 Debug 版本中尝试它会起作用吗?

    【讨论】:

      【解决方案2】:

      我在 Sonar 中看到了与 NCover 相同的行为。我发现 Sonar 正在为 Gallio 的 NCover 跑步者生成无效参数。

      尝试将 Sonar 运行器的输出通过管道传输到文本文件中,以便您可以更轻松地检查参数(在命令行上,您只需键入 sonar-runner > output.txt 即可)。

      您可能会在输出中看到这样的一行:

      INFO  .u.c.CommandExecutor - Executing command: C:\Program Files\Gallio\bin\Gallio.Echo.exe /r:Local /report-directory:E:\Reports\.sonar /report-name-format:gallio-report /report-type:Xml E:\Projects\UnitTests\bin\Release\UnitTests.dll /runner-property:NCoverCoverageFile=E:\Reports\.sonar\coverage-report.xml /runner-property:NCoverArguments=//ias MyFirstAssembly;MySecondtAssembly;MyThirdAssembly
      

      如果您尝试在命令行中通过 Gallio 手动执行此操作,您将收到错误:

      Cannot find file 'MyFirstAssembly;MySecondtAssembly;MyThirdAssembly'
      

      如果您手动将此列表编辑为单个条目,例如 MyFirstAssembly*,则一切都会按预期工作。

      这似乎表明 Sonar 正在为 Gallio 生成无效的命令行参数。尽管我很喜欢 NCover,但最简单的解决方案是改用 OpenCover。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-12-22
        • 2013-03-28
        • 2013-12-03
        • 2012-05-17
        • 2013-11-23
        • 2017-05-31
        • 2012-09-30
        • 2012-06-30
        相关资源
        最近更新 更多