MAVEN's test coverage plug-in integration, first modify the project's Pom.xml file, add the Cobertura-maven-plugin plugin as follows:
1. Environmental preparedness?
12345678910111213 |
<
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
?
12345678910 |
<
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
?
123456 |
mvn cobertura:help 查看cobertura插件的帮助 mvn cobertura:clean 清空cobertura插件运行结果 mvn cobertura:check 运行cobertura的检查任务 mvn cobertura:cobertura 运行cobertura的检查任务并生成报表,报表生成在target/site/cobertura目录下 cobertura:dump-datafile Cobertura Datafile Dump Mojo mvn cobertura:instrument Instrument the compiled classes |
Test coverage plug-in Cobertura-maven-plugin