datastax / cassandra-quarkus

An Apache Cassandra(R) extension for Quarkus
Apache License 2.0
39 stars 28 forks source link

JAVA-2735: Exclude generated classes from the JaCoCo report (fixes #39) #156

Closed essobedo closed 3 years ago

essobedo commented 3 years ago

fixes #39

Motivation

Some classes are generated and affect the JaCoCo reports.

Modifications

Result

The JaCoCo report is no more affected by the generated classes.

NB: The test classes like CassandraEndpoint and CassandraNameConverterEndpoint have been removed from the project

adutra commented 3 years ago

Hi @essobedo thank you for your contribution!

In fact I think our jacoco setup is completely broken: it is not collecting any data at all for integration tests, only for unit tests. This is why you are not seeing any mapper-generated classes in the report: they only appear in integration tests.

So let me suggest the following:

  1. According to the guidelines here, let's add this snippet to the jacoco plugin configuration (in the parent pom):
        <executions>
          <execution>
            <id>prepare-agent-ut</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <destFile>${project.build.directory}/jacoco-ut.exec</destFile>
            </configuration>
          </execution>
          <execution>
            <id>prepare-agent-it</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <destFile>${project.build.directory}/jacoco-it.exec</destFile>
            </configuration>
          </execution>
          <execution>
            <id>report-ut</id>
            <goals>
              <goal>report</goal>
            </goals>
            <configuration>
              <dataFile>${project.build.directory}/jacoco-ut.exec</dataFile>
              <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>report-it</id>
            <goals>
              <goal>report</goal>
            </goals>
            <configuration>
              <dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
              <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
            </configuration>
          </execution>
        </executions>
  1. Now we can check the integration tests report. Indeed I see that your change fixes the problem with Quarkus-generated classes. But we still have mapper-generated classes showing up in the report:

image image

I think it would be nice to exclude all the classes whose names end with __MapperGenerated, wdyt?

essobedo commented 3 years ago

@adutra good catch, let me try it

essobedo commented 3 years ago

@adutra Should be fine now

essobedo commented 3 years ago

@adutra However, I'm not sure that having the code coverage of integration test classes is really useful but maybe I missed something

adutra commented 3 years ago

However, I'm not sure that having the code coverage of integration test classes is really useful but maybe I missed something

It's not. But at least we have something that works now. The next steps would be to consolidate reports and maybe the ability to report coverage of classes in runtime and deployment modules when running the integration tests. But we can look into it later.