【问题标题】:SonarQube does not execute C# tests - Unit Tests Coverage widget shows 0SonarQube 不执行 C# 测试 - 单元测试覆盖率小部件显示 0
【发布时间】:2014-07-15 10:48:08
【问题描述】:

我在 .NET C# 项目上运行 Sonar。 测量值正在显示,但覆盖率小部件显示为 0.0%,并且未执行任何单元测试。

我可能在我的配置中做错了什么,有人可以帮助发现它吗?

我正在使用 TeamCity Enterprise 8.0.4 在 SonarQube 服务器版本 3.7.2 上运行 sonar-runner.bat 版本 2.0 TeamCity 将 dotCover 设置为覆盖工具。

sonar-project.properties 文件包含:

# Project identification values
sonar.projectKey=edd-datamodel-dotnet
sonar.projectName=EDDI DataModel NET

# Info required for Sonar
sonar.sources=.
sonar.language=cs 
sonar.dotnet.visualstudio.testProjectPattern=*Tests.Unit*

# Project Information
sonar.links.homepage=http://localhost/wiki
sonar.links.ci=http://localhost:8080/viewType.html?buildTypeId=bt37
sonar.links.issue=http://localhost/secure/IssueNavigator.jspa?mode=hide&requestId=11509
sonar.links.scm=scm:svn:http://localhost/SVG/repos/Product/Microsoft.Net/EDDI

以及执行的日志:

DEBUG - Using directory D:\work\9ff348aa7c3c7d93\Barclays.EDD.DataModel.Tests.Unit\bin\Debug for project Barclays.EDD.DataModel.Tests.Unit with buildconfiguration Debug
DEBUG - Executing Gallio program...
DEBUG - - Gallio executable   : C:\Program Files\Gallio\bin\Gallio.Echo.exe
DEBUG - - OpenCover executable: C:\Program Files (x86)\JetBrains\dotCover\v2.1\Bin\dotCover.exe
DEBUG - - Coverage tool       : dotCover
DEBUG - - Runner              : LOCAL
DEBUG - - Report directory    : D:\work\9ff348aa7c3c7d93\.sonar
DEBUG - - Report file         : gallio-report
DEBUG - - Test assemblies     :
DEBUG - D:\work\9ff348aa7c3c7d93\Barclays.EDD.DataModel.Tests.Unit\bin\Debug\Barclays.EDD.DataModel.Tests.Unit.dll
DEBUG - - Working directory   : D:\work\9ff348aa7c3c7d93\.sonar
DEBUG - - dotCover include: 
DEBUG - - dotCover exclude: 
DEBUG - - Coverage report: D:\work\9ff348aa7c3c7d93\.sonar\coverage-report.xml
INFO  - Executing command: C:\Program Files (x86)\JetBrains\dotCover\v2.1\Bin\dotCover.exe a /TargetExecutable=C:\Program Files\Gallio\bin\Gallio.Echo.exe /TargetWorkingDir=D:\work\9ff348aa7c3c7d93\.sonar "/TargetArguments=\"/r:Local\" \"/report-directory:D:\work\9ff348aa7c3c7d93\.sonar\" \"/report-name-format:gallio-report\" \"/report-type:Xml\" \"D:\work\9ff348aa7c3c7d93\Barclays.EDD.DataModel.Tests.Unit\bin\Debug\Barclays.EDD.DataModel.Tests.Unit.dll\"" /Filters=+:module=Barclays.EDD.DataModel;class=*;function=*;+:module=Build;class=*;function=*; /ReportType=TeamCityXML /Output=D:\work\9ff348aa7c3c7d93\.sonar\coverage-report.xml
INFO  - JetBrains dotCover Console Runner v2.1.471.44. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
INFO  - 
DEBUG - Updating semaphore batch-edd-datamodel-dotnet
INFO  - [JetBrains dotCover] Coverage session started [26/05/2014 15:31:14]
INFO  - 
INFO  - Gallio Echo - Version 3.4 build 11
INFO  - Get the latest version at http://www.gallio.org/
INFO  - 
INFO  - Start time: 15:31
INFO  - Initializing the runtime and loading plugins.
INFO  - Verifying test files.
INFO  - Initializing the test runner.
INFO  - test runner.' flowId='eac27e3d045b896d
INFO  - Running the tests.
INFO  - Running tests.' flowId='eac27e3d045b896d
INFO  - Barclays.EDD.DataModel.Tests.Unit (2s)
DEBUG - Updating semaphore batch-edd-datamodel-dotnet
INFO  - 
INFO  - 
INFO  - Generating reports.
INFO  - Disposing the test runner.
INFO  - Disposed test runner.' flowId='eac27e3d045b896d
INFO  - Stop time: 15:31 (Total execution time: 5.500 seconds)
INFO  - 
INFO  - 0 run, 0 passed, 0 failed, 0 inconclusive, 0 skipped
INFO  - 
INFO  - [JetBrains dotCover] Coverage session finished [26/05/2014 15:31:28]

任何帮助将不胜感激!

谢谢, 埃亚尔

【问题讨论】:

  • 我也有类似的问题。一切似乎都正常,但 dotCover 看不到任何单元测试方法。

标签: c# unit-testing sonarqube


【解决方案1】:

这看起来不寻常

DEBUG - - OpenCover executable: C:\Program Files (x86)\JetBrains\dotCover\v2.1\Bin\dotCover.exe
DEBUG - - Coverage tool       : dotCover

OpenCover 可执行文件实际上是OpenCover.Console.exe

您是在尝试运行 OpenCover 还是 dotCover?

【讨论】:

  • 默认情况下,TeamCity 正在运行 dotCover 我将尝试切换到 nCover 作为覆盖工具
【解决方案2】:

我有类似的问题。解决方案是添加:

sonar.gallio.runner=IsolatedProcess

我的 sonar-project.properties 文件的完整内容:https://sonartfs.codeplex.com/

【讨论】:

    猜你喜欢
    • 2022-07-01
    • 2018-10-18
    • 2014-05-04
    • 2020-11-14
    • 2014-02-21
    • 2014-10-25
    • 2014-08-06
    • 2015-03-13
    • 1970-01-01
    相关资源
    最近更新 更多