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

Specify source directory in clover config

We have a separate project for source and test. Also, the source files lie directly under src/ instead of src/main/java. The clover shows 0 coverage for these projects. Is there any setup we can do to make clover produce a correct coverage?

8 answers

You can use build-helper-maven-plugin:add-source/add-test-source to specify app/test source folders. Note that these goals shall be called before calling the clover2:setup goal. You can achieve this by binding them to different build phases in your pom.xml.

OK, so I did that but clover still shows me 0 code coverage for those projects. Is there any requirement to keep both source and test files under the same project?

Could you please tell what Maven command did you run? If you see your classes in the HTML report then it means that code was successfully instrumented by Clover. Having no 0% coverage means that no coverage recording files were produced (or found).

Possible causes:

  • no tests were executed (e.g. running 'mvn clover2:setup compile ...' instead of 'mvn clover2:setup test ...'
  • non-instrumented classes were taken for execution (for instance an xyz-N.N.N.war instead of xyz-N.N.N-clover.war was deployed)
  • clover.db was not found while running tests (e.g. due to a different working directory used for test execution; or execution on another machine)

... but I would have to see build logs to tell what went wrong.

Attaching the complete log, we can discuss about project, tests for which lie under, both having code under src/

Command ran:  mvn clean clover2:setup test clover2:aggregate clover2:clover -P clover


I've looked at the logs. And it seems that sources for both and modules are getting instrumented by Clover:

[INFO] ------------------------------------------------------------------------
[INFO] Building 2.3.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ ---
[INFO] Deleting D:\GitHub\repos\proj-app\\target
[INFO] Creating new database at 'D:\GitHub\repos\proj-app\\target\clover\clover.db'.
[INFO] Processing files at 1.7 source level.
[INFO] Clover all over. Instrumented 133 files (20 packages).
[INFO] Elapsed time = 3.593 secs. (37.016 files/sec, 2,399.388 srclines/sec)
[INFO] Building 2.3.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Creating new database at 'D:\GitHub\repos\proj-app\\target\clover\clover.db'.
[INFO] Processing files at 1.7 source level.
[INFO] Clover all over. Instrumented 48 files (6 packages).
[INFO] 97 test methods detected.
[INFO] Elapsed time = 1.491 secs. (32.193 files/sec, 2,401.744 srclines/sec)

I have couple of additional questions for you


  1. Could you tell more how you organize the tests and against what exactly they are being run? Are those simple JUnit tests or something else?
  2. Could you tell me more how you configure Clover, in which maven module did you put the configuration? The project itself contains one root project with multiple submodules or is the structure more complex? 
  3. Could you confirm that report written to the D:\GitHub\repos\proj-app\\target\site\clover\clover.xml file shows 0% coverage?
  4. Could you confirm that report written to the D:\GitHub\repos\proj-app\\target\site\clover/clover.xml file shows 0% coverage?
  5. Could you confirm existence of coverage files (named clover.dbHEXNUMBER) in the D:\GitHub\repos\proj-app\\target\clover directory?
  6. Could you confirm existence of coverage files (named clover.dbHEXNUMBER) in the D:\GitHub\repos\proj-app\\target\clover directory?
  7. Could you execute maven with -X switch in order to get more detailed logs and attach the output?


Best regards

Grzegorz Lewandowski

Thanks for the analysis. Here are the answers:
  1. These are eclipse rcp projects. There are separate projects each for source code and their tests. They don't follow the generic convention of directory hierarchy src|test/com/java. Instead, both source and tests in their own project lie directory under src/. These are simple Junit tests.
  2. proj-app contains all the modules, under which proj-parent and project-test-parent act as parents to all other projects. 

    	- proj-parent (parent to all non-.tests projects) (has a tycho atrifact as a parent)
    	- proj-test-parent (parent to all .tests projects) (has proj-parent as parent)

    Clover is configured in proj-parent.

  3. The metric for the project is

    <metrics conditionals="26" methods="13" classes="1" files="1" packages="1" coveredstatements="0" complexity="26" loc="314" ncloc="255" coveredmethods="0" coveredconditionals="0" statements="128" coveredelements="0" elements="167"/>

    The metric for the 6 packages are:

    <metrics classes="1" methods="13" conditionals="26" files="1" ncloc="255" coveredstatements="0" coveredmethods="0" complexity="26" coveredconditionals="0" statements="128" loc="314" coveredelements="0" elements="167"/>
    <metrics classes="38" methods="102" conditionals="6" files="38" ncloc="1562" coveredstatements="0" coveredmethods="0" complexity="105" coveredconditionals="0" statements="711" loc="2009" coveredelements="0" elements="819"/>
    <metrics classes="1" methods="6" conditionals="6" files="1" ncloc="85" coveredstatements="0" coveredmethods="0" complexity="10" coveredconditionals="0" statements="47" loc="114" coveredelements="0" elements="59"/>
    <metrics classes="1" methods="3" conditionals="0" files="1" ncloc="39" coveredstatements="0" coveredmethods="0" complexity="3" coveredconditionals="0" statements="12" loc="48" coveredelements="0" elements="15"/>
    <metrics classes="4" methods="24" conditionals="56" files="3" ncloc="452" coveredstatements="0" coveredmethods="0" complexity="60" coveredconditionals="0" statements="225" loc="635" coveredelements="0" elements="305"/>
    <metrics classes="1" methods="19" conditionals="0" files="1" ncloc="190" coveredstatements="0" coveredmethods="0" complexity="19" coveredconditionals="0" statements="128" loc="250" coveredelements="0" elements="147"/>
    <metrics classes="3" methods="5" conditionals="0" files="3" ncloc="157" coveredstatements="0" coveredmethods="0" complexity="5" coveredconditionals="0" statements="107" loc="211" coveredelements="0" elements="112"/>

    The first two metrics are for the same package but shown twice by clover. That package in all has 39 files. There seems to be an issue since the project metric here shows packages=1 while it actually has 6.

  4. The metric for the project is

    <metrics conditionals="1222" methods="771" classes="149" files="133" packages="20" coveredstatements="0" complexity="1425" loc="8621" ncloc="6734" coveredmethods="0" coveredconditionals="0" statements="2890" coveredelements="0" elements="4883"/>
  5. There exists a file named clover.db in D:\GitHub\repos\proj-app\\target\clover

  6. There exists a file named clover.db in D:\GitHub\repos\proj-app\\target\clover

You can't use Clover with Tycho plugin in a standard way. The problem is that Tycho plugin ignores Maven's source roots. More details here:

Thanks a lot guys to locate the issue. I followed the steps specified in the link and facing some issues:

  1. We are not using tycho-compiler-plugin. Does it need to be configured for workaround to work? We do use tycho-surefire-plugin which I have configured as specified in the link.
  2. On executing  mvn -X clover2:instrument -DcloverOutputDirectory=../proj_instr, I am getting error 

    [ERROR] Failed to execute goal org.eclipse.tycho:tycho-packaging-plugin:0.16.0:package-feature (default-package-feature) on project Execution default-package-feature of goal org.eclipse.tycho:tycho-packaging-plugin:0.16.0:package-feature failed: does not provide an artifact with classifier 'null' -> [Help 1]


    I am not able to understand this error. Is this error due to some missing configuration in project or tycho or clover?

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 Trel...

24 views 0 4
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