Code coverage in maven build - Skipping JaCoCo execution due to lack of classes

I can get code coverage that works fine if I have one project, but now I have a multi-module project.

My application is built in a project apiand all of my integration tests are performed in a separate project, which uses an artifact created as the previous module.

The build is done, but I do not get a code coverage report, instead I get an informational message:

Skipping JaCoCo execution due to missing classes directory

My report file has been jacoco-it.execcreated, but it looks like the plugin jacoconeeds classes in the project where the tests are running.

Can someone tell me what I need to do to be able to generate a coverage report when classes are in another module?

+8
source share
1 answer

I managed to get a workaround going through the trial version and an error.

It seems that the jacoco plugin is happy to create an exec file without classes, but it will not generate a report without them, I don’t understand how jacoco works inside, so if anyone knows, can you explain this?

I'm also not sure what I did is reliable, but it seems to reflect the scope of my tests caused by selenium.

My (possible) solution I came up with is to use the maven resource plugin to copy the classes that were blown from the war file in my target \ load directory .. to the target \ classes directory:

 <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>copy-resources</id>             
            <phase>pre-integration-test</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/classes</outputDirectory>
              <resources>          
                <resource>
                  <directory>${basedir}/target/cargo/configurations/tomcat7x/webapps/calculator-api/WEB-INF/classes</directory>
                  <filtering>false</filtering>
                  <excludes>
                        <exclude>**/*Config*.*</exclude>
                        <exclude>**/*Initialiser*.*</exclude>
                  </excludes>
                </resource>
              </resources>              
            </configuration>            
          </execution>
        </executions>
    </plugin>

, jacoco , , , .

- , , "" , - , , , exclude jacoco .

jacoco, , , , jacoco.

+5

All Articles