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?
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: https://confluence.atlassian.com/display/CLOVER/Using+Clover+for+web+applications
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<Optimizable> classes = Lists.newArrayList(); classes.add(new StringOptimizable("com.foo.Class1Test")); classes.add(new StringOptimizable("com.foo.Class2Test")); ... // run test optimizer TestOptimizer optimizer = new TestOptimizer("path/to/clover.db", "path/to/clover.snapshot"); List<Optimizable> 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); snapshot.store()
4) Is there a sample project that I can refer?
Unfortunately, I do not have any example for GNUmake.
Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...
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!
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