White-box testing-logic coverage and logic coverage

Source: Internet
Author: User

White-box testing-logic coverage and logic coverage

White-box testing is also called structure testing, transparent box testing, logic-driven testing, or code-based testing. White box testing is a test case design method. The box refers to the tested software, and the white box refers to the visible box, you know what is inside the box and how it works. The "white box" method provides a comprehensive understanding of the internal logic structure of the program and tests all logical paths. The "white box" method is to test the exhaustive path. When using this scheme, the tester must check the internal structure of the program and obtain the test data starting from the logic of the program.

The coverage standards of the white box test method include logical coverage, cyclic coverage, and basic path testing. Today, we focus on logic coverage, including statement coverage, decision coverage, condition coverage, decision/condition coverage, condition combination coverage, and path coverage.

Is a common program flow chart, which contains two judgment statements and two copy statements, and four paths L1: ace, L2: abd, L3: abe, L4: acd.

1. The statement overwrites each statement and is executed at least once.

We can create a test case (, 4) to overwrite all the statements (including the judgment statement and value assignment statement) in the graph, that is, the L1 path, which does not overwrite all the paths, therefore, statements have the lowest coverage.

2. Decision coverage is also called branch coverage. It not only executes each statement once, but also every possible decision is executed once.

To achieve the coverage of the decision, we can create two test cases (, 4) (, 1), so that the true and false conditions of each decision in the two judgments in the figure are all executed. The two test cases can only cover the L1 and L2 paths. Therefore, the coverage ratio is higher than the statement coverage, but the logic coverage is not very mild.

3. The conditions cover all possible values for each criterion.

Here we need to explain the difference between the condition and the judgment. There are two judgments in each judgment. Each judgment has two conditions, that is, A> 1 and B = 0, which are one condition respectively, the two conditions are combined into a decision. Condition determination overwrite overwrites every possible condition of each condition in each decision. Similarly, test cases (, 4) (, 1) can meet the conditions of coverage. We may see that these two test cases meet the conditions of decision coverage and condition coverage, so what is the relationship between the two covers? It can be said that there is no definite relationship between the two of them, nor does it mean that if conditions are met, the decision coverage must be met, or if conditions are met, the decision coverage can be met once. However, conditional coverage is more complex, and test cases only need to cover all the conditions. In this example, only the two test cases meet both the conditions of decision coverage and condition coverage, I hope you will not be misled.

4. Both decision/condition coverage and decision coverage.

From this logical coverage, we can see that there is no inclusion relationship between conditional coverage and decision coverage, because if one of them contains the other, it is called decision/condition coverage without having to satisfy two overwrites at the same time. Because the test cases (, 4) (, 1) meet both the conditions of coverage and decision coverage, the two test cases must meet the conditions of decision/condition coverage, however, the decision/condition overwrite can also overwrite all paths.

5. Condition combinations cover each combination of conditions in each decision at least once.

The combination of condition values and test cases are as follows:

It can be seen that even if the coverage of condition combinations is complex, it does not cover all paths. Therefore, we need to overwrite logic coverage with higher intensity.

6. overwrite the path so that every possible path in the program can be executed at least once.

In the six types of coverage, only the path overwrites all the paths, But no matter which overwrites, the correctness of the program cannot be guaranteed. The purpose of the test is to find problems with the program, instead of proving that the program is okay, the above logic covers only some of your own learning. If you have any shortcomings, I hope you will criticize and correct them.


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.