SonarQube shows less coverage for code when java 8 is used

Viewed 167

I am running sonar on my spring-boot-based service, previously coverage was 75%, but after migrating sonar runner to java 11, My code coverage is 15%. I tested in some other services when I run tests with jdk11 image and sonar using JDK 11, I get proper coverage, but in this service because of some issue I don't want to run tests using JDK 11, what might be missing?

Configuration giving proper coverage (Note this is a different service)

.test: &test
  stage: test
  image: maven:3.8.1-openjdk-11-slim
  services:
    - mongo
    - docker:dind
  script:
    - mvn test -Dspring.profiles.active=$PROFILE
  tags:
    - build-devops
  artifacts:
    paths:
      - target/jacoco.exec
      - target/spotbugsXml.xml
      - target/dependency-check-report.xml
      - target/dependency-check-report.html
      - target/checkstyle-result.xml

sonarqube:
  stage: sonar
  image: maven:3.8.1-openjdk-11-slim
  script:
    - mvn -q -U -B verify --settings settings.xml sonar:sonar -DskipTests=true -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN

Configuration of service having issue

.test: &test
  stage: test
  image: maven:3.8.1-openjdk-8-slim
  services:
    - mongo
    - docker:dind
  script:
    - mvn  test -Dspring.profiles.active=local
    - mvn  test -Dspring.profiles.active=central
  tags:
    - build-devops
  artifacts:
    paths:
      - target/jacoco.exec
      - target/spotbugsXml.xml
      - target/dependency-check-report.xml
      - target/dependency-check-report.html
      - target/checkstyle-result.xml

sonarqube:
  stage: sonar
  image: maven:3.8.1-openjdk-11-slim
  script:
    - mvn -q -U -B verify sonar:sonar --settings settings.xml -DskipTests=true -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN
0 Answers
Related