Quantcast

Code coverage using Jacoco - Multi module Maven

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Code coverage using Jacoco - Multi module Maven

Alessia Prete
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Code coverage using Jacoco - Multi module Maven

Alessia Prete
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Code coverage using Jacoco - Multi module Maven

Alessia Prete
I changed in the module's pom the jacoco goal, like this:

<executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>

Now it generates the jacoco.exec

When run sonar from parent dir, I can see:

[INFO] [14:08:56.663] Sensor JaCoCoSensor...
[INFO] [14:08:56.663] Analysing /home/solaria/workspace/platform/api/target/jacoco.exec
[INFO] [14:08:57.815] Sensor JaCoCoSensor done: 1152 ms
[INFO] [14:08:57.815] Sensor SurefireSensor..


But when I browse in sonar web, I get 0% integration  test coverage and 0 test unit.

suggestion?

thanks,

Ale

2012/7/23 Alessia Prete <[hidden email]>
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

David Racodon-2
In reply to this post by Alessia Prete
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

Alessia Prete
Hi David,

yes basically in module's pom
instead of this :
<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

I put:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>

          <!-- The destination file for the code coverage report has to be set to the same value
               in the parent pom and in each module pom. Then JaCoCo will add up information in
               the same report, so that, it will give the cross-module code coverage. --> 

          <destFile>${project.basedir}/target/jacoco-it.exec</destFile>
        </configuration>
            <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in parent's pom this:

  <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
whit:
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.reportPath>

I haven't try to run the sample project, I'll do it right now.

Thanks!

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

Alessia Prete
Yes the sample project works perfectly.

2012/7/23 Alessia Prete <[hidden email]>
Hi David,

yes basically in module's pom
instead of this :
<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

I put:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>

          <!-- The destination file for the code coverage report has to be set to the same value
               in the parent pom and in each module pom. Then JaCoCo will add up information in
               the same report, so that, it will give the cross-module code coverage. --> 

          <destFile>${project.basedir}/target/jacoco-it.exec</destFile>
        </configuration>
            <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in parent's pom this:

  <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
whit:
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.reportPath>

I haven't try to run the sample project, I'll do it right now.

Thanks!

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

Alessia Prete
The difference with the sample project is that I don't have this:

parent
   ---> app 
         -->pom
    --> app-it
         -->pom
pom


but something like this:

platform
    -->api  
          -->src
          -->test(unit and integration)
    -->pom
pom

So basically I'm copying what is in app-it 's pom in api's pom.

Don't know if it's ok,..

Thanks

Ale

2012/7/23 Alessia Prete <[hidden email]>
Yes the sample project works perfectly.


2012/7/23 Alessia Prete <[hidden email]>
Hi David,

yes basically in module's pom
instead of this :
<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

I put:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>

          <!-- The destination file for the code coverage report has to be set to the same value
               in the parent pom and in each module pom. Then JaCoCo will add up information in
               the same report, so that, it will give the cross-module code coverage. --> 

          <destFile>${project.basedir}/target/jacoco-it.exec</destFile>
        </configuration>
            <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in parent's pom this:

  <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
whit:
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.reportPath>

I haven't try to run the sample project, I'll do it right now.

Thanks!

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale






Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

Evgeny Mandrikov
Hi,

From https://github.com/SonarSource/sonar-examples/blob/master/projects/code-coverage/ut/ut-maven-multimodule-jacoco-runTests/README.md : "This example demonstrates how to collect code coverage by integration tests, which located in a separate module." I suppose that this is not your case.

On Mon, Jul 23, 2012 at 8:41 PM, Alessia Prete <[hidden email]> wrote:
The difference with the sample project is that I don't have this:

parent
   ---> app 
         -->pom
    --> app-it
         -->pom
pom


but something like this:

platform
    -->api  
          -->src
          -->test(unit and integration)
    -->pom
pom

So basically I'm copying what is in app-it 's pom in api's pom.

Don't know if it's ok,..

Thanks

Ale

2012/7/23 Alessia Prete <[hidden email]>
Yes the sample project works perfectly.


2012/7/23 Alessia Prete <[hidden email]>
Hi David,

yes basically in module's pom
instead of this :
<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

I put:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>

          <!-- The destination file for the code coverage report has to be set to the same value
               in the parent pom and in each module pom. Then JaCoCo will add up information in
               the same report, so that, it will give the cross-module code coverage. --> 

          <destFile>${project.basedir}/target/jacoco-it.exec</destFile>
        </configuration>
            <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in parent's pom this:

  <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
whit:
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.reportPath>

I haven't try to run the sample project, I'll do it right now.

Thanks!

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale









--
Best regards,
Evgeny Mandrikov aka Godin <http://godin.net.ru>
http://twitter.com/_godin_
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

David Racodon-2
In reply to this post by Alessia Prete
Hi Ale,

To help me understand your use case, when you say: "every module has src/main and src/test (with both UT and IT)", you mean:
  • UT =  Unit Tests = tests that only test source code from the module itself
  • IT = Integration Tests = tests that test source code from other modules
or
  • UT and IT both test source code from the module itself

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 16:41, Alessia Prete <[hidden email]> wrote:
The difference with the sample project is that I don't have this:

parent
   ---> app 
         -->pom
    --> app-it
         -->pom
pom


but something like this:

platform
    -->api  
          -->src
          -->test(unit and integration)
    -->pom
pom

So basically I'm copying what is in app-it 's pom in api's pom.

Don't know if it's ok,..

Thanks

Ale

2012/7/23 Alessia Prete <[hidden email]>
Yes the sample project works perfectly.


2012/7/23 Alessia Prete <[hidden email]>
Hi David,

yes basically in module's pom
instead of this :
<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

I put:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>

          <!-- The destination file for the code coverage report has to be set to the same value
               in the parent pom and in each module pom. Then JaCoCo will add up information in
               the same report, so that, it will give the cross-module code coverage. --> 

          <destFile>${project.basedir}/target/jacoco-it.exec</destFile>
        </configuration>
            <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in parent's pom this:

  <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
whit:
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.reportPath>

I haven't try to run the sample project, I'll do it right now.

Thanks!

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale







Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

Alessia Prete
the first:

  • UT =  Unit Tests = tests that only test source code from the module itself
  • IT = Integration Tests = tests that test source code from other modules
Anyway Evgeny is right..it's not my case.Sorry.

Looking better, seems there isn't an example for my case, right?

Thanks

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

To help me understand your use case, when you say: "every module has src/main and src/test (with both UT and IT)", you mean:
  • UT =  Unit Tests = tests that only test source code from the module itself
  • IT = Integration Tests = tests that test source code from other modules
or
  • UT and IT both test source code from the module itself

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 16:41, Alessia Prete <[hidden email]> wrote:
The difference with the sample project is that I don't have this:

parent
   ---> app 
         -->pom
    --> app-it
         -->pom
pom


but something like this:

platform
    -->api  
          -->src
          -->test(unit and integration)
    -->pom
pom

So basically I'm copying what is in app-it 's pom in api's pom.

Don't know if it's ok,..

Thanks

Ale

2012/7/23 Alessia Prete <[hidden email]>
Yes the sample project works perfectly.


2012/7/23 Alessia Prete <[hidden email]>
Hi David,

yes basically in module's pom
instead of this :
<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

I put:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>

          <!-- The destination file for the code coverage report has to be set to the same value
               in the parent pom and in each module pom. Then JaCoCo will add up information in
               the same report, so that, it will give the cross-module code coverage. --> 

          <destFile>${project.basedir}/target/jacoco-it.exec</destFile>
        </configuration>
            <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in parent's pom this:

  <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
whit:
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.reportPath>

I haven't try to run the sample project, I'll do it right now.

Thanks!

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale








Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

David Racodon-2
OK, so it cannot be achieved with your current project structure.
You need to externalize your ITs into specific modules, what seems to be a more logical structure from my point of view.
Then for :
  • "Standard" modules, take app pom file as an example (basically you don't have anything to do)
  • IT modules, take app-it pom file as an example

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 16:56, Alessia Prete <[hidden email]> wrote:
the first:

  • UT =  Unit Tests = tests that only test source code from the module itself
  • IT = Integration Tests = tests that test source code from other modules
Anyway Evgeny is right..it's not my case.Sorry.

Looking better, seems there isn't an example for my case, right?

Thanks

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

To help me understand your use case, when you say: "every module has src/main and src/test (with both UT and IT)", you mean:
  • UT =  Unit Tests = tests that only test source code from the module itself
  • IT = Integration Tests = tests that test source code from other modules
or
  • UT and IT both test source code from the module itself

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 16:41, Alessia Prete <[hidden email]> wrote:
The difference with the sample project is that I don't have this:

parent
   ---> app 
         -->pom
    --> app-it
         -->pom
pom


but something like this:

platform
    -->api  
          -->src
          -->test(unit and integration)
    -->pom
pom

So basically I'm copying what is in app-it 's pom in api's pom.

Don't know if it's ok,..

Thanks

Ale

2012/7/23 Alessia Prete <[hidden email]>
Yes the sample project works perfectly.


2012/7/23 Alessia Prete <[hidden email]>
Hi David,

yes basically in module's pom
instead of this :
<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

I put:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>

          <!-- The destination file for the code coverage report has to be set to the same value
               in the parent pom and in each module pom. Then JaCoCo will add up information in
               the same report, so that, it will give the cross-module code coverage. --> 

          <destFile>${project.basedir}/target/jacoco-it.exec</destFile>
        </configuration>
            <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in parent's pom this:

  <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
whit:
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.reportPath>

I haven't try to run the sample project, I'll do it right now.

Thanks!

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale









Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Code coverage using Jacoco - Multi module Maven

Alessia Prete
yes..I guess so.
I'll try.

Thanks!

2012/7/23 David Racodon <[hidden email]>
OK, so it cannot be achieved with your current project structure.
You need to externalize your ITs into specific modules, what seems to be a more logical structure from my point of view.
Then for :
  • "Standard" modules, take app pom file as an example (basically you don't have anything to do)
  • IT modules, take app-it pom file as an example

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 16:56, Alessia Prete <[hidden email]> wrote:
the first:

  • UT =  Unit Tests = tests that only test source code from the module itself
  • IT = Integration Tests = tests that test source code from other modules
Anyway Evgeny is right..it's not my case.Sorry.

Looking better, seems there isn't an example for my case, right?

Thanks

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

To help me understand your use case, when you say: "every module has src/main and src/test (with both UT and IT)", you mean:
  • UT =  Unit Tests = tests that only test source code from the module itself
  • IT = Integration Tests = tests that test source code from other modules
or
  • UT and IT both test source code from the module itself

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 16:41, Alessia Prete <[hidden email]> wrote:
The difference with the sample project is that I don't have this:

parent
   ---> app 
         -->pom
    --> app-it
         -->pom
pom


but something like this:

platform
    -->api  
          -->src
          -->test(unit and integration)
    -->pom
pom

So basically I'm copying what is in app-it 's pom in api's pom.

Don't know if it's ok,..

Thanks

Ale

2012/7/23 Alessia Prete <[hidden email]>
Yes the sample project works perfectly.


2012/7/23 Alessia Prete <[hidden email]>
Hi David,

yes basically in module's pom
instead of this :
<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

I put:

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>

          <!-- The destination file for the code coverage report has to be set to the same value
               in the parent pom and in each module pom. Then JaCoCo will add up information in
               the same report, so that, it will give the cross-module code coverage. --> 

          <destFile>${project.basedir}/target/jacoco-it.exec</destFile>
        </configuration>
            <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in parent's pom this:

  <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
whit:
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.reportPath>

I haven't try to run the sample project, I'll do it right now.

Thanks!

2012/7/23 David Racodon <[hidden email]>
Hi Ale,

Could you highlight what you've changed because I cannot spot those changes?
If you run the sample project out of the box, does everything works fine?

Thank you

Regards,

David RACODON | SonarSource
Senior Consultant



On 23 July 2012 13:19, Alessia Prete <[hidden email]> wrote:
Hi,

I'm trying to get code coverage using Jacoco.
following this example:

Till now I haven't been able to make it works.

My project is multi-module Maven.

every module has src/main and src/test (with both UT and IT) 

Just to try I modified just  one module (api) pom the destination file, like described in the example:

 <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
<!-- The destination file for the code coverage report has to be set to the same value
in the parent pom and in each module pom. Then JaCoCo will add up information in
the same report, so that, it will give the cross-module code coverage. -->
          <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
        </configuration>
        <executions>
          <execution>
            <id>post-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

And modified parent's pom (plataform)  like this:


In the module I cannot see any jacoco-it.exec, and when I run sonar from parent I get:
Project coverage is set to 0% as no JaCoCo execution data has been dumped: /home/solaria/workspace/platform/api/../target/jacoco-it.exec

What am I missing?

Thanks!

Ale










Loading...