Sonar does not shows up Code Coverage after build successful with Jenkins Sonar plugin

后端 未结 5 1043
囚心锁ツ
囚心锁ツ 2021-02-05 12:49

I am trying to get code coverage with Sonar and Jenkins. I see Jenkins\' Sonar plugin successfully executes JUnit test cases and completes build successfully. But Sonar does not

5条回答
  •  天涯浪人
    2021-02-05 13:36

    Just because Sonar invoked Surefire correctly (and you received the "Unit test success" message) doesn't mean that JaCoCo instrumented your code.

    Try executing JaCoCo directly. You might find out why JaCoCo is failing directly:

    mvn jacoco:prepare-agent test jacoco:report

    JaCoCo will place jacoco.exec as well as its XML/HTML reports within target/jacoco. Or it will fail, and hopefully you'll have a better idea as to why.

    One very common problem is that the JaCoCo javaagent will not run if you've changed the Surefire argLine at all, because jacoco:prepare-agent just sets the argLine property which in this scenario, is conveniently ignored. You can set prepare-agent's propertyName property to something else (like jacocoArgLine) and include that in your argLine config:

    -Xmx1024m ${jacocoArgLine}

提交回复
热议问题