jacoco

Exclude package from Jacoco coverage in Jenkins

别来无恙 提交于 2019-12-13 06:30:55
问题 Trying to exclude packages from coverage report as my Jenkins pipeline fail. I have a sub project with all POJO:s. I don't want to write uittest for all these. Hence, they will drag down branch/line coverage som that coverage will be below threshold and fail my build. It should be possible to exclude some packages, but I cant get it to work. I have the following jacoco.gradle file: apply plugin: 'jacoco' apply plugin: 'java' jacoco { toolVersion = "0.8.2" } jacocoTestReport { reports { xml

How to generate HTML report with SonarQube-6.7.5

孤街浪徒 提交于 2019-12-13 03:13:06
问题 I am working on Spring4.0 Project with apache-maven-3.5.4 and Java 1.8 and would like to use SonarQube for code coverage and reports. I am using jacoco-maven-plugin 0.7.8 version plugin for that. I am able to see the details in the browser. But when I try to generate the report to HTML, I am not seeing the reports generated. I did a lot of research in Google and I followed the below mvn sonar:sonar -Dsonar.issuesreport.html.enable=true and i added the entry in POM as well. But the reports are

SpringBoot Junit Maven JaCoCo

人盡茶涼 提交于 2019-12-13 02:22:10
写一下最近写单体测试的一些笔记. SrpingBoot的测试用例: @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = {ApiApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 如果需要加其他配置, 可以使用SrpingBoot的Configuration, 来引入其他资源, 比如本次就引入了excel作为配置文件. 之所以选择excel,是因为exce可以作为嵌入式数据库来用,编辑数据方便灵活,没有其他嵌入数据库可以与之相比, 可以加入vba编程, 种种好处.本想用MongDB, 还是算了,高冷难用. ------------- mvn 命令行启动 mvn -Dtest=ApiTestSuit -DfailIfNoTests=false test mvn test mvn -Dtest=TestControllerTest#test -DfailIfNoTests=false test 启动目录在root pom所在目录.-Dtest=xxxx的时候, 会去每个子pom所在项目的test中找xxxx的测试, 会报错, 所以需要加上-DfailIfNoTests=false ----------

Filtering coverage with Lombok, Gradle, Jacoco and Sonar

风格不统一 提交于 2019-12-12 18:30:24
问题 I'm using Gradle 4.4 on my Java project with JaCoCo 0.8.0, and Sonar with SonarJava 5.0.1. I have a class annotated with lombok's @Value and @Builder . My JaCoCo config in build.gradle looks like this: jacoco { toolVersion = "0.8.0" reportsDir = file("$buildDir/reports/jacoco") } jacocoTestReport.doFirst{ classDirectories = files("buildDir/classes") } task jacocoReport(type: JacocoReport){ sourceSets sourceSets.main executionData test, integrationTest } Also, I have lombok.confi file, with

Gradle Jacoco - coverage reports includes classes excluded in configuration

放肆的年华 提交于 2019-12-12 10:35:07
问题 I added to a project a set of sources that don't have tests and I don't want them spoil my test coverage statistics. I configured Jacoco in the next way : test { jacoco{ excludes = ['org/bla/**'] includes = ['com/bla/**'] append = false } } jacocoTestReport { dependsOn test description = "Generate Jacoco coverage reports after running tests." reports { xml.enabled true html.enabled true } classDirectories = fileTree(dir: 'build/classes/main', include: 'com/bla/**') sourceDirectories =

Open JaCoCo report in Intellij IDEA

爱⌒轻易说出口 提交于 2019-12-12 07:39:41
问题 I am trying to find dead code on our application by using a code coverage tool (rather a static code analysis tool). I have chosen JaCoCo and am able to get a report thanks to the JaCoCo agent. I know that Intellij IDEA works with JaCoCo but I couldn't find anyway to import my JaCoCo report into Intellij IDEA. Any idea on how to do that? Thanks 回答1: Found the solution. I have installed the coverage plugin and the EclEmma plugin (not sure if this one is really necessary...). Then "Analyse ->

Jacoco jmx dump, Connection reset error

萝らか妹 提交于 2019-12-12 04:54:59
问题 I am running tomcat with a jacoco agent like this: -javaagent:/path_to_jar/jacocoagent.jar=jmx=true,output=tcpclient,port=8001 which I know is working because lsof command lists 88208 TCP localhost:**8001** (LISTEN) . When I run this example code with PORT = 8001; I get the error: Exception in thread "main" java.net.SocketException: Connection reset This appears to be an older example from jacoco. Has something changed with that way I need to access the tcp server? I have also tried to access

Adding jacoco integration tests coverage for Sonar

◇◆丶佛笑我妖孽 提交于 2019-12-12 03:24:38
问题 Background: I have 2 separate java projects, call them A and B. Project A is the actual product (war application), with unit-tests. Gradle builds the project and then runs sonar analysis, and I can see the unit-tests coverage in Sonar. Project B is an integration test for the first project. It is run by Jenkins in a pipeline after building project A and deploying it on an integration-environment. The deployment also involves instrumenting the code so that the jacoco-it report will correlate

How to ignore inner static classes in Jacoco when using Gradle

自闭症网瘾萝莉.ら 提交于 2019-12-12 03:16:50
问题 I know how to ignore classes defined in their own .java files, but not aware of how to ignore inner classes. For example, I have class A with nested class B: class A { ... static class B { ... } } jacocoTestReport keeps checking the coverage when I want to ignore them in jacoco.gradle file with this syntax(learned from this post: How to ignore inner/nested classes with JaCoCo?): ( setFrom part is for later versions of Gradle, where classDirectories = files() is deprecated) apply plugin:

Gradle JaCoCo plugin - class and method names not clickable in report

懵懂的女人 提交于 2019-12-12 02:16:25
问题 I've created a simple Java project which uses Gradle. I've added some unit tests and integrated JaCoCo plugin to see the code coverage. It all works well, however, in the HTML report I can't click on the class name to see exactly which lines and branches are covered. I have another project which uses Maven and JaCoCo where this functionality works. Is it a limitation of Gradle plugin, or am I doing something wrong? Here's my build.gradle: apply plugin: 'java' apply plugin: 'jacoco'