[Zz] Test Coverage

Source: Internet
Author: User
Software testing coverage includes branch coverage, statement coverage, and condition coverage. This is a basic test concept in white-box testing. However, I recently talked to several friends who have been conducting tests for many years, it is not clear to everyone. I will discuss this issue in depth through an example below: Let's take a look at the test coverage.Definition: Definition 1. Statement Overwrite: It requires that every executable statement of the program under test be tested as much as possible; Definition 2. branch coverage: All decision branches in the program should be tested as much as possible; Definition 3. Conditional coverage: When the criterion contains multiple conditions, the values of each condition must be verified; from these definitions, we can easily understand that statement overwrite overwrites all the statements in the program. Branch overwrite overwrites every branch in the program; conditional coverage overwrites all the conditions in the judgment condition. Here is a simple example to describe 0: 1: If (A <150) | (B <200) {2: for (I =; I <100; I ++) 3: {4: println ("A");} 5:} else {6: println ("B"); 7 :} Branch coverage:1) set a = 120 at 0, B will execute 200, 52) set a = 400 at 0, B = will execute, 6, 7 all the branches here go, that is to say, to reach the branch coverage rate of 100%, two groups of test cases should be designed
A B
120 Arbitrary
200 400
Statement overwrite:1) set a = 40 at 0, B will execute 1, 2, 3, 4, 52) set a = 200 at 0, B = 400 will execute 1, 5, 6, 7 all the statements here have come, that is to say, to reach the statement coverage rate of 100%, two groups of test cases should be designed.
A B
40 Arbitrary
200 400
In the branch overwrite, Statement 3, 4 does not go Conditional coverage:Because the first condition is if (A <150) | (B <200), you need to design a test case.
A B Remarks
40 50 All satisfied
160 150 A is not satisfied, B is satisfied
40 250 A is satisfied, B is not satisfied
150 250 Neither a nor B is satisfied.
You only need to overwrite all the conditions. In this way, we can clarify these concepts.

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.