Generates Code Coverage reports
13% of Grails users
Dependency :
test ":code-coverage:1.2.6"
Summary
Creates Code Coverage reports for your code
Description
Test Code Coverage Plugin
This plugin will generate code coverage reports using Cobertura.Please create issues in JIRA if you encounter problems.
To install:
For Grails 1.1
grails install-plugin code-coverage
For Grails versions prior to version 1.1
You need to install version 0.9 of the plugingrails install-plugin code-coverage 0.9
To run:
grails test-app -coverage
grails test-app-cobertura
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']
}Release History:
1.1.7 (2009 October 20)- GRAILSPLUGINS-1598: upgrade to cobertura 1.9.3
- GRAILSPLUGINS-1377: updating closure names in the xml report
- GRAILSPLUGINS-1278: plugins/code-coverage-1.1.5 files in WAR
- GRAILSPLUGINS-1516: ability to define xml output through configuration
- Added config and command line arguments to disable code coverage by default
- Change from using Config.groovy to BuildConfig.groovy to configure exclusions and custom properties
- support for Grails 1.1 RC2
- upgraded to Cobertura 1.9
- Removed TestAppCobertura script, plugin now utilizes the events framework to tie into the main Grails test-app script
- added ability to override exclusions through config.coverage.exclusionListOverride
- added ability to bypass generation of code coverage through the -nocoverage flag
- support for Grails 1.1
- added post processing of HTML reports to display human readable names for controller actions (Controller.list instead of Controller.$_closure1)
- Support for Grails 1.0.4 (deprecated Events.groovy and use _Events.groovy instead)
- added default exclusions for the Grails Testing Plugin (grails/test/ and org/codehaus/groovy/grails/)
- add sourceInclusions config option
- updated the default codeCoverageExclusionList in TestAppCobertura.groovy to exclude 'Config' rather than '*Config*'
- Added scriptEnv = "test" so you no longer need to specify the environment when running the test-app-cobertura script
- fixed a bug where project specific exclusions were not being loaded correctly