Original: http://www.cnblogs.com/yucongblog/p/5297051.html
1. Environmental preparedness
<Project> ... <Reporting> <Plugins> <plugin> <groupId>Org.codehaus.mojo</groupId> <Artifactid>Cobertura-maven-plugin</Artifactid> <version>2.5.1</version> </plugin> </Plugins> </Reporting> ...</Project>
2. Check if the environment is successful
First Run "MVN cobertura:help" and if not, add the following warehouse
<Project> ... <pluginrepositories> <pluginrepository> <ID>Codehaus Repository</ID> <URL>http://repository.codehaus.org/</URL> </pluginrepository> </pluginrepositories> ...</Project>
3. Perform coverage statistics
Run MVN Coberura:coberura
If the operation is successful, see {project}\target\site\coberura\index.html
Such as
4.coberura Common Commands
Here is the command for the Cobertura plugin
MVN cobertura:help View Cobertura plug-in Help mvn cobertura:clean emptying Cobertura plug-in Run results mvn Cobertura:check Run Cobertura check task mvn cobertura:cobertura run Cobertura check task and generate report, report generated in Target/site/cobertura directory Cobertura: Dump-datafile Cobertura datafile Dump mojomvn cobertura:instrument instrument the compiled classes
Maven real-Test coverage plug-in use