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

0 votes

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
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

5,418 views 21 17
View question

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