clover with gnu make

We are using old build system GNU make to build java projects. Can I use clover to get  test code coverage for our integration tests and optimize the integration tests? is there a sample project that I can refer?

1 answer

This widget could not be displayed.

Hi Shankar, thanks a lot for great questions.


1) We are using old build system GNU make to build java projects. Can I use Clover [...] ?

Yes, it's possible. You can instrument Java sources using the CloverInstr command line tool:

and next use these instrumented sources as an input for javac.


2) Can I use Clover per test code coverage to get our integration per test coverage?

I assume that by integration tests you mean tests of an application running on a server - in other words, there are at least two JVMs running - one with unit tests and one with an application. Am I correct? If yes, then you have to enable Distributed Coverage feature. Example:

CloverInstr -dc ON

Please keep in mind that an application instrumented by Clover and running on a server must be able to locate the Clover database. Thus, in case your app server runs in a different working directory (than a build workspace) you have to either provide -Dclover.initstring=/path/to/clover.db JVM parameter or use an absolute path to a database during instrumentation:

CloverInstr -i /absolute/path/to/clover.db

You can find more hints here:


3) Can I [...] optimize the integration tests?

It depends how do you select and run your integration tests. For instance, do you call Ant's <junit> task for this? Or maybe you run some 'find' command to locate integration tests and next pass them to JUnit test runner manually?

The easiest way would be to try using the existing integrations in Clover (Ant, Maven ...) to optimize these tests.

However, if you cannot use this, you could try running Clover's com.atlassian.clover.api.optimization.TestOptimizer manually, but this would require some hacks. Code could look moreless like this:

// prepare list of test classes to be optimized
List&lt;Optimizable&gt; classes = Lists.newArrayList();
classes.add(new StringOptimizable(""));
classes.add(new StringOptimizable(""));

// run test optimizer
TestOptimizer optimizer = new TestOptimizer("path/to/clover.db", "path/to/clover.snapshot");
List&lt;Optimizable&gt; optimizedClasses =  optimizer.optimize(classes)

// run tests using the optimizedClasses list 

// update the optimization snapshot
CloverDatabase db = CloverDatabase.loadWithCoverage("path/to/clover.db", new CoverageDataSpec());
Snapshot snapshot = Snapshot.generateFor(db);


4) Is there a sample project that I can refer?

Unfortunately, I do not have any example for GNUmake.


Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

121 views 2 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you