JaCoCo for Integration Test Coverage

593 views
Skip to first unread message

Rohan Kulkarni

unread,
Feb 27, 2017, 1:08:50 PM2/27/17
to JaCoCo and EclEmma Users

11:51 AM (less than a minute ago)
Hi, I am having a hard time to get JaCoCo plugin working to get integration test (IT) coverage for my Spring boot app with Maven.

Here's my configuration for the jacoco-maven-plugin for IT:


<execution>
  <id>pre-integration-test</id>
  <phase>pre-integration-test</phase>
  <goals>
       <goal>prepare-agent</goal>
   </goals>
   <configuration>
       <destFile>${sonar.jacoco.itReportPath}</destFile>
    </configuration>
</execution>
<execution>
    <id>post-integration-test</id>
    <phase>post-integration-test</phase>
    <goals>
        <goal>report</goal>
     </goals>
    <configuration>
        <dataFile>${sonar.jacoco.itReportPath}</dataFile>
        <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
     </configuration>
</execution>

And we are using the spring-boot-maven-plugin for running the integration tests as below,


<plugin>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-maven-plugin</artifactId>
   <version>1.3.7.RELEASE</version>
   <executions>
      <execution>
         <id>pre-integration-test</id>
         <goals>
              <goal>start</goal>
         </goals>
         <configuration>
              <fork>false</fork>
              <arguments>
                    <argument>--server.port=${flex.module.port}</argument>
                    <argument>--logging.config=${project.basedir}/src/test/resources/test-log4j.xml</argument>
                    <argument>--server.tomcat.accesslog.enabled=false</argument >
                    <argument>--server.tomcat.basedir=${project.build.directory}</argument>
              </arguments>
         </configuration>
      </execution>
      <execution>
          <id>post-integration-test</id>
          <goals>
               <goal>stop</goal>
          </goals>
      </execution>
   </executions>
</plugin>

When I run "mvn clean verify" I see the following error,

--- jacoco-maven-plugin:0.7.7.201606060606:report (post-integration-test) @ se-service ---
[INFO] Skipping JaCoCo execution due to missing execution data file.

      Looks like the .exec file is not getting generated by the Agent. Any help would be appreciated ?

Thanks
Rohan
Auto Generated Inline Image 1

Evgeny Mandrikov

unread,
Feb 27, 2017, 3:35:08 PM2/27/17
to JaCoCo and EclEmma Users
As stated in documentation about "prepare-agent" mojo at page http://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html :

Prepares a property pointing to the JaCoCo runtime agent that can be passed as a VM argument to the application under test.

By default it will set "argLine" property, but spring-boot-maven-plugin doesn't take into account this property by default and you're not passing it explicitly , hence spring-boot-maven-plugin starts JVM without agent.

Rohan Kulkarni

unread,
Feb 27, 2017, 3:52:12 PM2/27/17
to JaCoCo and EclEmma Users
I tried passing it explicitly in the spring-boot-maven-plugin but it still did not generate the exec file for integration test. I can see it is setting the argLine property correctly in the pre-integration-test step. Not sure why that agent is not getting started.

Rohan

Evgeny Mandrikov

unread,
Feb 27, 2017, 4:16:05 PM2/27/17
to JaCoCo and EclEmma Users
Maybe because you also have "<fork>false</fork>" that disables forking of JVM ?

Also clear that excerpt of pom.xml is not enough to reproduce your difficulty. So please provide full runnable example.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages