1.Concept
Cobertura is an excellent open source test coverage statistics tool that, in combination with unit test code, marks and analyzes what code was executed when the test package was run and what code was not executed and what branch of the condition was passed to measure test coverage. In addition to finding the code that has not been tested and discovering bugs ,Cobertura can also refine the code by tagging useless, code-less execution, resulting in an aesthetically detailed HTML Coverage Detection report.
2. MavenIntegratedCobertura2.1 Pom.xmlConfiguration
<!-- Test coverage plug-in --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId> cobertura-maven-plugin</artifactid> <configuration> < formats> <format>html</format> <format>xml</format> </formats> </ configuration> </ Plugin>
2.2Run
Running in the project root directory
MVN Cobertura:cobertura
Output Result:
Project_base$\target\site\cobertura\index.html
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/82/FA/wKiom1dnq7ih8PZ5AAE1iXEu8Bg903.png "title=" 1.png " alt= "Wkiom1dnq7ih8pz5aae1ixeu8bg903.png"/>
3.Statistical Indicators
Code Coverage = (number of code/code measured) * 100%.
3.1Row Overlay
Linecoverage
It is also called a statement overlay or a basic block overlay. This is a more commonly used and representative indicator of whether each executable statement in the code being measured is executed.
3.2Conditional override
Branchcoverage
It measures whether the presence of branches in a contemporary code can overwrite the two cases of entering and not branching. This requires developers to write multiple test cases to meet the two cases of entering and not branching respectively.
3.3Path Overlay
3.4Complexity of
Complexity
This article is from the "10950988" blog, please be sure to keep this source http://10960988.blog.51cto.com/10950988/1791055
Cobertura code test coverage use cases