Test Code Coverage Plugin
15% of Grails users
Dependency:
test "org.grails.plugins:code-coverage:2.0.3-3"
Summary
Creates Code Coverage reports for your code
Description
Test Code Coverage Plugin
This plugin will generate code coverage reports using Cobertura.Currently Grails Forked mode is not supported.
To run:
grails test-app -coverage
Command line options:
By default, the script will create HTML reports and place them in the tests/report/cobertura directory. If you would prefer XML reports (e.g for a Continuous Integration server), specify the-xml
flag like this:grails test-app -coverage -xml
Controller.list
instead of Controller.$_closure1
). If you don't require this or it is too resource intensive, you can tell the plugin to skip post processing of HTML files by passing the -nopost
flag.grails test-app -coverage -nopost
grails test-app -coverage
grails test-app -nocoverage
-nopost
and -xml
flags but can't from the command line, they can be defined in BuildConfig.groovy:coverage { nopost = true xml = true }
Configuration Options:
If you want to disable coverage by default, you can set the enabledByDefault config attribute equal to falsecoverage {
enabledByDefault = false
}
coverage { exclusions = ["**/ExcludedController*", "**/excludedDir/**"] }
//cobertura exclusions
coverage {
exclusions = [
'**/de/andreasschmitt/richui/taglib/renderer/**',
'**/plugins/richui-0.4/src/groovy/de/andreasschmitt/richui/**',
'**/de/andreasschmitt/richui/image/**',
'**/org/jsecurity/**',
'**/org/jsecurity/grails/**',
'**/JsecDbRealm*',
'**/*TagLib*/**',
"**/*Tests*",
'**/JsecAuthBase*',
'**/JsecurityFilters*']
}
"**/*BootStrap*", "Config*", "**/*DataSource*", "**/*resources*", "**/*UrlMappings*", "**/*Tests*", "**/grails/test/**", "**/org/codehaus/groovy/grails/**", "**/PreInit*", "*GrailsPlugin*"
coverage { exclusionListOverride = [ "**/grails/test/**", "*GrailsPlugin*"] }
coverage {
// list of directories to search for source to include in coverage reports
sourceInclusions = ['grails-app/realms']
}