Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Maven +Openclover generate aggrigate test report for multi-module project

directfn_devops July 6, 2020

Dears,

Parent.pom
     module1.pom
         target/clover/module1Clover.db
     module2.pom
         target/clover/module2Clover.db
    module3.pom
        target/clover/module3Clover.db
    plkModule


I want to merge all 3 modules clover dbs in to one db in PlkModule and have a report(test coverage report) ,
How to do this? Could you please advice?

 

Regards

Raveendra

1 answer

0 votes
Richard White _TechTime_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 6, 2020

Hi Raveendra,

We do this in a couple of our projects and it is not too tricky.

The aggregate goal will merge all of the moduleXClover.DB into a single db and then you can use the clover task to generate the report.

For example, if running locally, and you have the open-clover plugin specified in your pom.xml  you can run:

mvn clover:setup test clover:aggregate clover:clover

The final "clover:clover" instruction will generage a report based on the merged database, which I think is the second part of your question.

Once it is working locally you can incorporate it in your bamboo build by exposing the report as an artifact and selecting "I already integrated a code coverage tool in this job." and putting in the path to the report.

directfn_devops July 6, 2020

Dear Richard

 

Thank you very much for your answer..!!!

 

Now I am getting "

'has 2 candidates, please provide a classifier.'

for one of a module.. Please advice.

"

Could you please advice , when giving maven goals as pom configuration, I am providing goals in my pom as "instrument,aggregate,clover,"

 

Please find below pom file...

<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>clover-maven-plugin</artifactId>

<configuration>

</configuration>
<executions>
<execution>
<phase>install</phase>
<!--<phase>pre-site</phase>-->
<goals>
<goal>instrument</goal>
<goal>aggregate</goal>
<goal>clover</goal>
</goals>
</execution>
</executions>
</plugin>

 

Regards

Raveendra

Richard White _TechTime_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 7, 2020

Hi Raveendra,

Unfortunately that's not an error I have seen before, and other than suggesting you use the newer open clover clover-maven-plugin,  I'm not sure what could be wrong with that configuration.

directfn_devops July 9, 2020

Thanks Richard for your reply!!.I  was able to generate coverage which is not much accurate form the below pom.


<plugin>
                <groupId>org.openclover</groupId>
                <artifactId>clover-maven-plugin</artifactId>
                <version>4.4.1</version>
                <configuration>
           
                    <flushPolicy>threaded</flushPolicy>
                    <flushInterval>30000</flushInterval>
                    <!--<includesTestSourceRoots>false</includesTestSourceRoots>-->
                </configuration>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <!--<phase>pre-site</phase>-->
                        <goals>
                            <!--<goal>clean</goal>-->
                            <goal>instrument-test</goal>
                            <goal>aggregate</goal>
                            <goal>clover</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

But After I added exclusions Coverage become zero.Please find below pom after adding  excludes. Could you please advice?


<plugin>
<groupId>org.openclover</groupId>
<artifactId>clover-maven-plugin</artifactId>
<version>4.4.1</version>
<configuration>

<excludes>
<exclude>**/*_InternalTmp.java</exclude>
</excludes>
<flushPolicy>threaded</flushPolicy>
<flushInterval>30000</flushInterval>
<!--<includesTestSourceRoots>false</includesTestSourceRoots>-->
</configuration>
<executions>
<execution>
<phase>install</phase>
<!--<phase>pre-site</phase>-->
<goals>
<!--<goal>clean</goal>-->
<goal>instrument-test</goal>
<goal>aggregate</goal>
<goal>clover</goal>
</goals>
</execution>
</executions>
</plugin>

Regards

Raveendra

Richard White _TechTime_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 10, 2020

Hi again Raveendra,

I personally I would try the goals

- clean

- instrument (not instrument-test)

- aggregate

- clover

For testing I would remove the flush policy and flushInterval and just use the default settings. I am assuming you are just doing coverage for unit tests via surefire at the moment, not trying to get coverage for integration or functional tests?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events