No Coverage despite unit tests on an open source project

sonarcloud

(Benoit) #1

Hi

I love SonarCloud.io and I have 2 open source projects there (thank you!). Unfortunately, one of them does not seem to report any coverage despite having some unit tests running.

I must have stuffed up my pom.xml for Flatpack but I cannot see it and this is driving me nuts.

https://sonarcloud.io/organizations/benoitx-github/projects

As you can see, one project reports coverage and the other one (Flatpack) does not.

Any pointer toward my mistakes would be greatly appreciated.

Thanks!
Benoit


(Evgeny Mandrikov) #2

Hi Benoit,

If you try to generate native JaCoCo report ( report goal of jacoco-maven-plugin ) , I’m pretty sure that this one will also be empty. To me seems that reason is that JaCoCo agent is not actually used during execution of tests and this is pretty common mistake described in JaCoCo documentation - see https://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html , which states:

If your project already defines VM arguments for test execution, be sure that they will include property defined by JaCoCo.

define “argLine” as a Maven property rather than as part of the configuration of maven-surefire-plugin:

<properties>
  <argLine>-your -extra -arguments</argLine>
</properties>
...
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <!-- no argLine here -->
  </configuration>
</plugin>

However you do exactly opposite

Hope this helps.


Jacoco.exec for maven multimodule project is not
(Benoit) #3

Wow Evgeny… thank you for that! It seems to work.

Benoit