Jacoco Integration test report is not correct

1.3k views Asked by At

I have a restful api and the workflow of integration test cases is that we build the project -> Then start a tomcat using maven on a predefined port -> Deploy the built war on that tomcat instance and then maven runs the integration test cases with respect to that war. Build is succeeded only if the unit as well as integration test cases pass. I want to generate code coverage report for integration as well unit test cases. Though Jacoco is correctly generating report for unit test cases but it is not generating the correct report for integration test cases . As in all the folders are shown with zero percent coverage.

<plugin>
      <groupId>org.jacoco</groupId>
      <artifactId>jacoco-maven-plugin</artifactId>
      <version>0.7.4.201502262128</version>
      <executions>
            <execution>
                  <id>default-report</id>
                  <phase>prepare-package</phase>
                  <goals>
                        <goal>report</goal>
                  </goals>
            </execution>
            <execution>
                  <id>pre-unit-test</id>
                  <goals>
                        <goal>prepare-agent</goal>
                  </goals>
                  <configuration>
                        <destFile>${basedir}/target/jacoco-unit.exec</destFile>
                        <propertyName>surefireArgLine</propertyName>
                  </configuration>
            </execution>
            <execution>
                  <id>post-unit-test</id>
                  <phase>test</phase>
                  <goals>
                        <goal>report</goal>
                  </goals>
                  <configuration>
                        <dataFile>${basedir}/target/jacoco-unit.exec</dataFile>
                        <append>true</append>
                  </configuration>
            </execution>
            <execution>
                  <id>pre-integration-test</id>
                  <phase>pre-integration-test</phase>
                  <goals>
                        <goal>prepare-agent-integration</goal>
                  </goals>
                  <configuration>
                        <destFile>${basedir}/target/jacoco-it.exec</destFile>
                        <propertyName>failsafeArgLine</propertyName>
                  </configuration>
            </execution>
            <execution>
                  <id>post-integration-test</id>
                  <phase>verify</phase>
                  <goals>
                        <goal>report</goal>
                  </goals>
                  <configuration>
                        <includes>
                        </includes>
                        <dataFile>${basedir}/target/jacoco-it.exec</dataFile>
                        <outputDirectory>${basedir}/target/site/jacoco-it</outputDirectory>
                  </configuration>
            </execution>
      </executions>
</plugin>

On failsafe plugin :

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-failsafe-plugin</artifactId>
      <version>2.17</version>
      <configuration>
            <includes>
                  <include>**/*IT.java</include>
            </includes>
            <argLine>${failsafeArgLine}</argLine>
            <skipTests>false</skipTests>
      </configuration>
      <executions>
            <execution>
                  <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                  </goals>
                  <configuration>
                        <includes>
                              <include>**/*IT.java</include>
                        </includes>
                  </configuration>
            </execution>
      </executions>
</plugin>
0

There are 0 answers