jacoco

SonarQube + Maven + JaCoCo + GitLab CI: Sonar started to show 0% code coverage after upgrading to SonarQube 7.9.2

无人久伴 提交于 2020-04-17 22:07:46
问题 After we upgraded our SonarQube to Version 7.9.2 (build 30863), Community Edition , running the GitLab CI Pipeline results in showing 0.0% coverage (dropping from about 86.2% ), although Sonar is showing all unit tests. Maven build executed in .gitlab-ci.yml looks like this: - mvn test sonar:sonar -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONAR_TOKEN} Obviosuly this has something to deal with notorious sonar.coverage.jacoco.xmlReportPaths and sonar.jacoco.reportPaths Sonar-JaCoCo

SonarQube + Maven + JaCoCo + GitLab CI: Sonar started to show 0% code coverage after upgrading to SonarQube 7.9.2

无人久伴 提交于 2020-04-17 22:05:53
问题 After we upgraded our SonarQube to Version 7.9.2 (build 30863), Community Edition , running the GitLab CI Pipeline results in showing 0.0% coverage (dropping from about 86.2% ), although Sonar is showing all unit tests. Maven build executed in .gitlab-ci.yml looks like this: - mvn test sonar:sonar -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONAR_TOKEN} Obviosuly this has something to deal with notorious sonar.coverage.jacoco.xmlReportPaths and sonar.jacoco.reportPaths Sonar-JaCoCo

Jacoco code coverage dropped with migration to Java 11

青春壹個敷衍的年華 提交于 2020-04-16 15:02:09
问题 I have several Gradle projects that were built using Java 8, and after converting them recently to use Java 11, Jacoco code coverage reports have been reporting much lower percentages than before. On one project, immediately after the transition, my coverage dropped from 81% to 16%. I tried updating the Jacoco plugin to 0.8.3 (which has official JDK 11 support), Gradle to 5.4, and TestNG to 6.14.3 (not sure if this has any effect; thought it couldn't hurt to be on the latest version). Even

Gradle这篇文章就够用了11-Gradle与CI/CD插件集成

倾然丶 夕夏残阳落幕 提交于 2020-04-06 17:59:56
Gradle与CI/CD插件集成 结合JUnit进行单体测试 在build.gradle中添加testImplementation,例如 buildscript { ext { springBootVersion = '2.1.1.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group = 'com.orrincn' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { implementation('org.springframework.boot:spring-boot-starter-web') testImplementation('org

iOS自动化探索(十)代码覆盖率统计

馋奶兔 提交于 2020-04-04 06:03:47
Android 代码覆盖率统计 本周开始准备统计Android自动化用例的代码覆盖率,将最终使用的方法记录下来。 覆盖率监测的原理 覆盖率监测的原理跟iOS上的原理差不多,大致的思路参考下吧, iOS自动化探索(十)代码覆盖率统计 Android使用的是JaCoCO覆盖率统计工具 jacoco 原理篇 必要知识储备或条件: 项目源码 Android Studio开发环境 基本了解Android项目结构 基础adb操作 同样如果以上说的几个都不懂也行, 让开发帮忙做这些然后编个代码覆盖率统计的包给你测试, 测完把手机给开发取数据生成报告。 注意每次测试完先返回手机桌面把程序退到后台等几秒让app自己生成日志文件 下面开始讲步骤 步骤1:拉取项目代码 git clone XXXXXXXXXXX 步骤2:使用Android Studio打开项目 步骤3:配置build.gradle apply plugin: 'com.android.application' apply plugin: 'jacoco' //加载代码覆盖库jacoco jacoco { toolVersion = "0.7.9" //代码覆盖库jacoco版本号 } android { compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig {

sonarqube不再支持jacoco coverage非xml格式的报告, 只通过sonar.coverage.jacoco.reportXmlPaths支持xml

拜拜、爱过 提交于 2020-03-06 17:22:06
jacoco是一个开源的,目前使用比较普遍的java语言的覆盖率计算工具,它默认生成的是.exec格式的覆盖率报告。sonarqube是做代码静态扫描的平台,它可以将jacoco计算的覆盖率上传到自己的平台上,然后根据指定的规则来做一些分析。sonarqube最新的8.x的版本开始不支持.exec这种格式的报告了(也就是参数sonar.jacoco.reportPaths是不支持的了),jacoco要生成xml格式的报告才能被sonarqube识别(sonar.coverage.jacoco.reportXmlPaths)。 官方文档的说明, https://docs.sonarqube.org/pages/viewpage.action?pageId=1442166 但文档并没有说具体从哪个版本不支持。 一、首先来看如何适应sonarqube的改动 下面来看如何让jacoco生成xml格式的报告,其实很简单,在build.gradle中添加这样一个设置就好了,打开xml格式,关闭csv和html格式。 jacocoTestReport { reports { xml.enabled true csv.enabled false html.enabled false } } 然后在执行的时候把这个task添加到参数里才可以 ./graldew jacocoTestReport

Cross-module code coverage with Jacoco offline instrumentation in gradle mutlimodule project

我是研究僧i 提交于 2020-02-20 05:28:26
问题 I have to use Jacoco offline instrumentation in my project because there is PowerMock that is used as well. The issue description: suppose you have gradle project with two modules: A, B. Module A has tests that cover a code from the module B . On code coverage data collection I figured out that coverage data(should be provided by the module A ) for the module B is completely missed. I've created a test project that demonstrates the issue: https://github.com/SurpSG/jacoco-offline

通过代码方式使用Jacoco远程统计tomcat服务的代码覆盖率

百般思念 提交于 2020-02-14 18:36:44
1)修改远程tomcat下的bin/catalina.sh中JAVA_OPTS的配置 ---------------------------------------------------------------- # -javaagent: 的后面跟jacoco的安装路径 # includes= 选项,选择你要覆盖率的服务 # port= 选项,选择你要打开的端口 # address= 选项,tomcat服务所在机器的ip地址(如果想在跟tomcat服务同一台机器上执行ant任务的话,需要改为127.0.0.1) JAVA_OPTS="-javaagent:/path/to/your/jacoco_0.8.5/lib/jacocoagent.jar=includes=com.*,output=tcpserver,port=8893,address=10.81.14.77" 2)在开发环境pom.xml中引入jacoco的jar包 <!--使用jacoco对web工程生成全部的覆盖率报告--> <dependency> <groupId>org.jacoco</groupId> <artifactId>org.jacoco.core</artifactId> <version>0.8.5</version> </dependency> <dependency> <groupId

Exclude classes of jar files from jacoco coverage report

只愿长相守 提交于 2020-02-03 06:44:20
问题 Jacoco code coverage report is also including classes from "system path jar" that I have added using below maven dependency <dependency> <groupId>axis</groupId> <artifactId>axis</artifactId> <version>1.2.1</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/axis-1.2.1.jar</systemPath> </dependency> I tried to exclude the files of this jar from jacoco plugin like this : <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId>

Exclude classes of jar files from jacoco coverage report

人盡茶涼 提交于 2020-02-03 06:39:00
问题 Jacoco code coverage report is also including classes from "system path jar" that I have added using below maven dependency <dependency> <groupId>axis</groupId> <artifactId>axis</artifactId> <version>1.2.1</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/axis-1.2.1.jar</systemPath> </dependency> I tried to exclude the files of this jar from jacoco plugin like this : <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId>