Search code examples
javawindowsjunit5jacoco-maven-plugin

Jacoco plugin fails for JUnit5 with no coverage


Here at unit-api we recently migrated from JUnit4 to JUnit5. Unfortunately, there are some complications, though. To be more specific, once we migrated, the build completes successfully for OSX, but fails for Windows OS.

Our setup is:

  • jacoco-maven-plugin at v.0.8.2
  • JUnit5

You can read more about the specific issue here.

Any ideas?


Solution

  • After some testing and reading I think the issue is related to how Jacoco deals with multi-release-JARs or builds.

    I have added following modification to your POM.xml:

    <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.plugin.version}</version>
        <configuration>
          <excludes>
            <exclude>META-INF/**</exclude>
          </excludes>
        </configuration>
    </plugin>
    

    For simplicity here I did not include all the <execution> settings.

    Running a build then using mvn clean verify site results in properly populated reports in target\site\jacoco. The HTML, XML and CSV reports then seem to be complete, no empty files anymore.

    There are also some related StackOverflow questions and an issue at Jacoco Github:

    GitHub:

    StackOverflow: