Cobertura code test coverage use cases

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.