Excluding database migration changelog files from cobertura coverage in Grails

This took me a while to figure out so I thought it was worth a quick post. As is clear from the Grails Cobertura plugin documentation it is possible to exclude certain classes or packages from the coverage reports. This is very useful where there are classes such as configuration files that are impossible or pointless to test, and impact negatively on the results of your code coverage. Take this example which excludes all your typical Grails config and resources files.
coverage {
   exclusions = ["*Config*", "*Resources*"]
}
In the case of Cobertura changelog files, the natural action is to add an exclude based on the assumption that the changelog is a Class, like so:
coverage {
   exclusions = ["*Config*", "*Resources*", "*changelog*"]
}
But that assumption turned out to be wrong. The changelog is actually the package name so you need to add the following to get the desired exclusions:
coverage {
   exclusions = ["*Config*", "*Resources*", "**/*changelog*/**"]
}
A nice bump in the code coverage numbers - for very little work!

Comments

  1. Florida Personal Injury Attorney Sinclair Law - Leading Florida Law Firm Attorney Brad Sinclair Represents Personal Injury, Car Accident, Motorcycle Accident Victims in Melbourne.

    ReplyDelete

Post a Comment

Popular posts from this blog

AngularJs: User friendly date display with AngularJs and MomentJs

Nerd Tree: A File Explorer with Mac Vim

Getting started with Grails functional tests using Geb + Spock