ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

java-SonarQube不收集代码覆盖率

2019-11-21 15:03:52  阅读:692  来源: 互联网

标签:jacoco sonarqube gradle java


我在与声纳运行器和jacoco设置gradle时遇到问题.除了代码覆盖范围之外,一切都很好.我已经尝试了所有没有结果的东西.

这是我的build.gradle文件:

apply from: './dependencies.gradle'

def langLevel = 1.8

allprojects {
  apply plugin: 'idea'
  apply plugin: 'eclipse'

  group 'pl.lodz.uml.sonda'
  version '1.0.0'
}

subprojects {
  apply plugin: 'java'
  apply plugin: 'sonar-runner'
  apply plugin: 'jacoco'

  compileJava.options.encoding = 'UTF-8'

  sourceCompatibility = langLevel
  targetCompatibility = langLevel

  repositories {
    mavenLocal()
    mavenCentral()
  }

  jacoco {
    toolVersion = "0.7.0.201403182114"
  }

  sonarRunner {
    sonarProperties {
      property 'sonar.host.url', 'http://localhost:9000'
      property 'sonar.login', 'admin'
      property 'sonar.password', 'admin'

      property 'sonar.jdbc.url', 'jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8'
      property 'sonar.jdbc.driverClassName', 'com.mysql.jdbc.Driver'
      property 'sonar.jdbc.username', 'sonar'
      property 'sonar.jdbc.password', 'sonar'

      property 'sonar.jacoco.reportPath', "${buildDir}/jacoco/test.exec"
      property 'sonar.junit.reportsPath', "${buildDir}/test-results"
    }
  }

  dependencies {
    compile deps.spring.context
    testCompile deps.test
  }
}

project(':sonda-uml-common') {
  dependencies {

  }
}

project(':sonda-uml-integration') {
  dependencies {
    compile deps.spring.web
    compile deps.javax.servlet
  }
}

当我运行sonarRunner任务时,这是控制台的输出:

22:36:31: Executing external task 'sonarRunner'...
:sonda-uml-integration:compileJava
:sonda-uml-integration:processResources
:sonda-uml-integration:classes
:sonda-uml-integration:compileTestJava
:sonda-uml-integration:processTestResources UP-TO-DATE
:sonda-uml-integration:testClasses
:sonda-uml-integration:test
:sonda-uml-integration:sonarRunner
22:36:37.780 INFO  - Load batch settings
22:36:37.911 INFO  - User cache: C:\Users\Piotr\.sonar\cache
22:36:37.919 INFO  - Install plugins
22:36:38.003 INFO  - Install JDBC driver
22:36:38.013 INFO  - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
22:36:38.954 INFO  - Initializing Hibernate
22:36:41.073 INFO  - Load project settings
22:36:41.123 INFO  - Apply project exclusions
22:36:41.157 WARN  - 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
22:36:41.312 INFO  - -------------  Scan sonda-uml-integration
22:36:41.317 INFO  - Load module settings
22:36:41.710 INFO  - Loading technical debt model...
22:36:41.718 INFO  - Loading technical debt model done: 8 ms
22:36:41.718 INFO  - Loading rules...
22:36:42.080 INFO  - Loading rules done: 362 ms
22:36:42.095 INFO  - Configure Maven plugins
22:36:42.148 INFO  - Compare to previous analysis (2014-06-28)
22:36:42.153 INFO  - Compare over 30 days (2014-05-29, analysis of 2014-06-28 19:27:48.0)
22:36:42.154 INFO  - No quality gate is configured.
22:36:42.277 INFO  - Base dir: D:\projects\sonda-uml\sonda-uml-integration
22:36:42.277 INFO  - Working dir: D:\projects\sonda-uml\sonda-uml-integration\build\sonar
22:36:42.277 INFO  - Source dirs: D:\projects\sonda-uml\sonda-uml-integration\src\main\resources, D:\projects\sonda-uml\sonda-uml-integration\src\main\java
22:36:42.278 INFO  - Test dirs: D:\projects\sonda-uml\sonda-uml-integration\src\test\resources, D:\projects\sonda-uml\sonda-uml-integration\src\test\java
22:36:42.279 INFO  - Binary dirs: D:\projects\sonda-uml\sonda-uml-integration\build\classes\main, D:\projects\sonda-uml\sonda-uml-integration\build\resources\main
22:36:42.279 INFO  - Source encoding: windows-1250, default locale: pl_PL
22:36:42.279 INFO  - Index files
22:36:42.341 INFO  - 5 files indexed
22:36:42.962 INFO  - Quality profile for java: Sonar way
22:36:42.974 INFO  - Sensor JavaSquidSensor...
22:36:43.022 INFO  - Java Main Files AST scan...
22:36:43.027 INFO  - 4 source files to be analyzed
22:36:43.628 INFO  - 4/4 source files analyzed
22:36:43.630 INFO  - Java Main Files AST scan done: 608 ms
22:36:43.634 INFO  - Java bytecode scan...
22:36:43.679 INFO  - Java bytecode scan done: 45 ms
22:36:43.680 INFO  - Java Test Files AST scan...
22:36:43.680 INFO  - 1 source files to be analyzed
22:36:43.683 INFO  - Java Test Files AST scan done: 3 ms
22:36:43.686 INFO  - 1/1 source files analyzed
22:36:43.690 INFO  - Package design analysis...
22:36:43.741 INFO  - Package design analysis done: 51 ms
22:36:43.795 INFO  - Sensor JavaSquidSensor done: 821 ms
22:36:43.796 INFO  - Sensor QProfileSensor...
22:36:43.828 INFO  - Sensor QProfileSensor done: 32 ms
22:36:43.829 INFO  - Sensor InitialOpenIssuesSensor...
22:36:43.840 INFO  - Sensor InitialOpenIssuesSensor done: 11 ms
22:36:43.841 INFO  - Sensor ProfileEventsSensor...
22:36:43.859 INFO  - Sensor ProfileEventsSensor done: 18 ms
22:36:43.859 INFO  - Sensor ProjectLinksSensor...
22:36:43.864 INFO  - Sensor ProjectLinksSensor done: 5 ms
22:36:43.864 INFO  - Sensor VersionEventsSensor...
22:36:43.941 INFO  - Sensor VersionEventsSensor done: 77 ms
22:36:43.941 INFO  - Sensor FileHashSensor...
22:36:43.942 INFO  - Sensor FileHashSensor done: 1 ms
22:36:43.942 INFO  - Sensor CpdSensor...
22:36:43.943 INFO  - SonarEngine is used for java
22:36:43.944 INFO  - Cross-project analysis disabled
22:36:43.963 INFO  - Sensor CpdSensor done: 21 ms
22:36:43.964 INFO  - Sensor SurefireSensor...
22:36:43.964 INFO  - parsing D:\projects\sonda-uml\sonda-uml-integration\build\test-results
22:36:44.021 INFO  - Sensor SurefireSensor done: 57 ms
22:36:44.021 INFO  - Sensor JaCoCoSensor...
22:36:44.024 INFO  - Analysing D:\projects\sonda-uml\sonda-uml-integration\build\jacoco\test.exec
22:36:44.043 WARN  - Coverage information was not collected. Perhaps you forget to include debug information into compiled classes?
22:36:44.043 INFO  - Sensor JaCoCoSensor done: 22 ms
22:36:44.341 INFO  - Execute decorators...
22:36:44.884 INFO  - Store results in database
22:36:45.051 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/pl.lodz.uml.sonda:sonda-uml-integration
22:36:45.161 INFO  - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
22:36:45.161 INFO  - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
22:36:45.218 INFO  - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
22:36:45.225 INFO  - -> Keep one snapshot per day between 2014-05-31 and 2014-06-27
22:36:45.226 INFO  - -> Keep one snapshot per week between 2013-06-29 and 2014-05-31
22:36:45.226 INFO  - -> Keep one snapshot per month between 2009-07-04 and 2013-06-29
22:36:45.227 INFO  - -> Delete data prior to: 2009-07-04
22:36:45.231 INFO  - -> Clean sonda-uml-integration [id=10]
22:36:45.234 INFO  - <- Clean snapshot 127

BUILD SUCCESSFUL

Total time: 14.253 secs
22:36:45: External task execution finished 'sonarRunner'.

之后,在声纳中,我可以看到所有指标,但看不到代码覆盖率.
你知道这里会发生什么吗?

解决方法:

从现在开始,我认为您需要独立制作覆盖文件并将这些文件导入声纳.

对于C#代码,我们需要这样做.对于Java项目,我不确定,但可能是一个原因.

您可以通过此链接获取有关C#覆盖率更改的更多信息:http://docs.codehaus.org/display/SONAR/C%23+Plugin

标签:jacoco,sonarqube,gradle,java
来源: https://codeday.me/bug/20191121/2052743.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有