Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.
This repository was archived by the owner on Feb 13, 2026. It is now read-only.

JaCoCo support not working #65

Open

Description

@jsoltes

Jacoco code coverage tool should be supported since the version 1.1.5 (implemented by @rsauciuc ). However when we run jacoco on the sample project in this project, we are getting zero coverage. We are using following configuration in the parent pom:

<plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${version.jacoco.plugin}</version>
          <executions>
            <execution>
              <id>default-prepare-agent</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <configuration>
                <propertyName>surefire.argLine</propertyName>
              </configuration>
            </execution>
            <execution>
              <id>default-report</id>
              <phase>prepare-package</phase>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
            <execution>
              <id>default-check</id>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
                <haltOnFailure>${jacoco.haltOnFailure}</haltOnFailure>
                <rules>
                  <rule>
                    <element>BUNDLE</element>
                    <limits>
                      <limit>
                        <counter>LINE</counter>
                        <value>COVEREDRATIO</value>
                        <minimum>${jacoco.line.coveredratio.minimum}</minimum>
                      </limit>
                    </limits>
                  </rule>
                </rules>
              </configuration>
            </execution>
          </executions>
</plugin>

Activity

  1. nukesz commented on Apr 6, 2017

    @nukesz

    I experience the same thing when I use the @RunWith(GwtMockitoTestRunner.class), JaCoCo will not consider that test execution and report as 0% coverage. The GwtMockitoTestRunner uses javassist.Loader class for bytecode manipulation and as far as I know JaCoCo does not work if the class under test has been modified during runtime. My feeling is that GwtMockitoTestRunner has never worked with JaCoCo (regardless what the change log says).

  2. ekuefler commented on Apr 9, 2017

    @ekuefler
    Contributor

    I'm not particularly familiar with JaCoCo - @rsauciuc, can you comment if it is/was working for you?

    The only change in GwtMockito to support JaCoCo is to ensure that we use the standard classloader for everything under the org.jacoco package. Classes under test will go through the GwtMockito classloader to do things like stub native methods and unfinalize some methods, so if that process interferes with JaCoCo there might not be a fix. But we should leave the bytecode of normal methods untouched.

  3. rsauciuc commented on Apr 10, 2017

    @rsauciuc
    Contributor

    At the time I made the fix it was working for us, we were using JaCoCo in offline mode, doing bytecode instrumentation at build time.

    In a different project, we had a similar problem with the agent competing with other instrumentation to make changes to the class files, and we switched the flag (classdumpdir, I think) to write out the class files after they were transformed, so JaCoCo's report task could match the binary coverage data with the actual classes.

  4. jsoltes commented on Apr 11, 2017

    @jsoltes
    Author

    I have set jacoco to do the offline instrumentation and it is working even for classes annotated @RunWith(GwtMockitoTestRunner.class). So far this is the only way to make it work I know about.

  5. nukesz commented on Apr 13, 2017

    @nukesz

    Thanks @jsoltes , with offline instrumentation it works as excepted and shows the coverage.
    Maybe it will help for others, this is how I enabled it with maven:

        <properties>
            <jacocoVersion>0.7.9</jacocoVersion>
            <jacoco.skip.instrument>true</jacoco.skip.instrument>
        </properties>
    
        <dependencies>
            ...
            <dependency>
                <!--  must be on the classpath  -->
                <groupId>org.jacoco</groupId>
                <artifactId>org.jacoco.agent</artifactId>
                <classifier>runtime</classifier>
                <version>${jacocoVersion}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacocoVersion}</version>
                    <executions>
                        <execution>
                            <id>jacoco-instrument</id>
                            <goals>
                                <goal>instrument</goal>
                            </goals>
                            <configuration>
                                <skip>${jacoco.skip.instrument}</skip>
                            </configuration>
                        </execution>
                        <execution>
                            <id>default-restore-instrumented-classes</id>
                            <goals>
                                <goal>restore-instrumented-classes</goal>
                            </goals>
                            <configuration>
                                <skip>${jacoco.skip.instrument}</skip>
                            </configuration>
                        </execution>
                        <execution>
                            <id>default-report</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

    To execute without coverage

    mvn clean install

    With coverage (and instrument):

    mvn clean install -Djacoco.skip.instrument=false
  6. JonCook commented on Jun 22, 2017

    @JonCook

    Any idea how to do this for ant? Thanks

  7. zeitwesen commented on Sep 14, 2019

    @zeitwesen

    Should this still work with GWT 2.8.2 and GwtMockito + plain old JUnit Tests? Somehow do not get it to work at all. Does not even create the jacoco.exec file ("Skipping JaCoCo execution due to missing execution data file."). Anybody managed to find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions