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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can clover be used for getting code coverage for API integration tests written in TestNg

I have a spring boot application running in one JVM and I am running my integration tests in other JVM on same machine. I have confgured maven-clover2-plugin:4.0.4 to generate distrubted coverage.  I see that although during execution of API integration tests code in Controller and Service layer is executed, but in the coverage stats only the controller source is shown as covered and coverage is zero for Service layer.

here is my package structure -

Source Code package structure -

Test Code package structure -



1 answer

Hi Rohan,

Are controller and service classes located in different Maven modules? 

Are tests kept in the same module(s) as controller and service clasess?

Did the the application server shut down after tests?


Lack of code coverage for some of classes may be caused by different factors:

1) Service classes were not instrumented

 - check if you have any inclusion/exclusion patterns in maven-clover2-plugin configuration in pom.xml

 - check if you ran 'mvn clean' before calling clover2:setup (otherwise Maven could have found class files compiled previously and not compile the instrumented sources)

 - check if you see instrumented classes in /target/classes folder - you can recognize them by "<base name>$__CLR<hash>.class" name pattern


2) Wrong EAR/WAR content or wrong EAR/WAR deployed

 - depending on how EAR/WAR is assembled, it may happen that non-instrumented classes are packed (e.g. using a cached JAR file instead of the instrumented classes) 

 - ensure that instrumented classes are present inside the WAR/EAR file you deploy for tests


3) Database not found at runtime

  - it may happen if you have several Maven modules and you copied only one clover.db file to your application server instead of all clover.db files

 - this usually does not happen if you build & test on the same machine, unless you launch an application from a different working directory than build workspace  - as Clover uses relative paths in initstring

 - check for any Clover-related errors in application log, such as

CLOVER: Unable to load the coverage database at <path>
CLOVER: No coverage data will be gathered.


4) Coverage file were not written to disk at the time when report was created

 - by default Clover uses "direct" flush policy, which means that coverage recording files are written at JVM shutdown hook

 - therefore in case you killed an application server (kill -9) or when you did not close the application server (i.e. it runs also after tests are finished) coverage files could have not been written to disk

 - ensure that application sever is stopped or change flush policy to "interval" or "threaded"



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Trello

📹 What is a Trello board?

Hi, Atlassian Community! My name is Brittany Joiner and I am a Trello enthusiast and Atlassian Community Leader. I'll be sharing with you a series of videos with my top tips on how to best use Tre...

14 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you