Groovy per-test instrumentation


I am using the Ant tasks to create code coverage for Groovy and Java files. For Groovy files I do not see any per-test coverage in my HTML report. For Java classes this works fine. In my Ant clover-setup task I define the patterns **/* as well as **/*Test.groovy as filesets for testsources. I do the same when using the task clover-report. The manual states that you need to use fully qualified class names in your test sources for annotations and classes. I tried that but it still doesn't do it (also I think that this is not usable). Is this still true with Clover 3.1? How does the Grails plugin do the trick. It looks like I am missing something. Any help would be highly appreciated.



1 answer

0 votes

Hi Benjamin,

Please have a look at the Test+Optimization+Quick+Start+Guide+for+Ant chapter "Running Java and Groovy test cases".

According to Ant documentation, the <junit>/<batchtest> collects the included resources from any number of nested resource collections and then generates a test class name for each resource that ends in .java or .class. It means that if you put *.groovy extension, such files will be ignored.

However, you can pass compiled classes to junit Ant task, for instance:

<fileset dir="${build.dir}">
    <include name="**/*Test.class"/>

Then Ant will find both Java and Groovy tests.

Please bear in mind that currently Clover cannot optimize Groovy test cases. An improvement CLOV-1152 will solve this problem.


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,711 views 3 11
Read article

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