The basic method of software testing (II.) white box test

Source: Internet
Author: User

White box test

Concept: According to the internal structure of the program test procedures, through testing to determine whether the internal action of the product according to the specifications of the design specification of normal. Each route in the inspection procedure is able to work correctly according to the predetermined requirements.


Category: White box testing is a test based on coverage. Overwrite the structure and logical path of the program as much as possible. Therefore, the detailed method has logical coverage, loop coverage, and basic path coverage. The logic overlay can be further divided into statement coverage, decision (branch) coverage, conditional coverage, decision-conditional coverage, conditional combination coverage, and so on.

The white box test is mainly used for unit testing (we need to understand the program source code and structure, and based on the input and output. Suitable for unit modules). The following focuses on several commonly used white-box test methods.


Statement overrides:

Definition: only requires overwriting to all of the operational statements (run at least once per run statement), without concern for the inference operation, ensuring that there are no errors at the running statement.


Examples:



According to the White box, we just need to cover all the running statements. And for this we only need to test the example (x=1. y=4,z=9). So three words will be printed out.

But assume that the encoding x=1 and y>3 errors are written x=1 OR y>3. Although our test sample can cover all the running statements, it proves that the statement can be run correctly. But so our password system is at great risk. Y will be able to break the first line of defense just above 3.

And we don't know about it. So the statement overlay does not meet our needs (some say it is the weakest logical coverage criterion).


Decision (branch) Overrides:

Definition: Each inferred branch of truth and the taking of false branches are experienced at least once. Compensate for the lack of statement coverage for inference logic.


Example: Ibid.

    • (X=1. Y=4,Z=9)--Through the path t->t
    • (x=0,y=4,z=0)-by Path f->f
The above two test examples. The true and false values of the two inferred conditions are traversed, which is the minimum test example for running a judgment overlay. This way, when X=1 and Y>3 are mistakenly written as X=1 OR Y>3, the second Test example can find an error.

But suppose the chosen test example is (x=0. y=0,z=0) still cannot find the error.

Try the following overrides.
conditional override: definition: To satisfy the true or false of each condition in every inference.
Example: Ibid. the first inference has two conditions x=1 and y>3, and the second inference has a conditional z=9.

    • (x=1,y=4. z=9)--x=1 true. Y>3 really. Z=9 really
    • (x=0,y=0,z=0)-- x=1 fake, y>3, z=9 fake
is also a two test example can be. There are two problems with this overlay:
    • Still can't solve that or problem.
    • Suppose the selected test example is (x=1,y=2. z=9) and (x=0,y=4,z=0). Although the conditional overrides are met, the first inference only runs the bogus branch, which omits the logic error.


decision--conditional override:definition: Is the combination of the decision coverage and the conditional coverage. Ensure that the true and false of each condition in each inference is met at least once, and at the same time each inferred branch and take-false branch is experienced at least once.
Example: Ibid.
    • (X=1. Y=4,Z=9)
    • (x=0,y=0,z=0)
In this way, both the true and false branches of each inference are taken, and the truth of every condition in each inference is taken. But this same cannot solve the or problem--when and is mistakenly written to or, the running path of the two use cases is the same, so it is not possible to detect errors with these two use cases alone.


conditional combination overrides: definition: For each inference. The true or false value of the condition in the combination if the inference consists of two conditions. Then should design t1t2, T1F2, f1t2, f1f2 this kind of combination), and let each deduce the true and false value to take.
Example: Ibid.

    • (X=1. Y=4. z=9)--x=1 True, Y>3 True, z=9 true-overwrite path: t-t
    • (x=1,y=0,z=0)--x=1 true. Y>3 false, Z=9 false --cover path: F-f
    • (x=0,y=4,z=9)--x= 1 off. Y>3 really. z=9 true --Overwrite path: f-t
    • (x=0,y=0,z=0)--x= 1 False, y>3 false. Z=9 false --Overwrite path: f-f
When the or problem occurs, the path to the second to third use case is changed. Aware of the error. This overcomes the or problem, because the combination of true and false in the first inference is the fundamental means of distinguishing between and and OR.

Although the or problem has been overcome. But we found a path that did not cover the--t-f.
Path Overrides: definition: Overrides all potentially running paths.
Example: Ibid. Let's change the second use case based on the conditional combination override use case.

    • (x=1,y=4,z=9)--x=1 true, Y>3 true. Z=9 true-Overlay path: t-t
    • (X=1. y=4,z=0)--x=1 True, Y>3 true, z=9 false--coverage path: t-f
    • (x=0,y=4,z=9)--x=1 false, Y>3 true. Z=9 true-Overlay path: f-t
    • (x=0. y=0,z=0)--x=1 false, Y>3 false, z=9 false--cover path: F-f
Although the paths are covered. However, the path overlay does not cover all of the conditional combinations.
Summary:
It can be seen that there is no cover that completely covers all of the test examples. Therefore, in the actual test example design, a variety of coverage is often combined to achieve the highest coverage. In this case, finally, the trial example is covered by the path overlay on the basis of the conditional combination overlay.

    • (x=1,y=4. z=9)--x=1 true. Y>3 true, z=9 true-overwrite path: t-t
    • (x=1,y=0,z=0)--x=1 true. Y>3 false. Z=9 false--Overwrite path: f-f
    • (x=0. Y=4. Z=9)--x=1 false, Y>3 true. Z=9 true-Overlay path: f-t
    • (x=0,y=0. z=0)--x=1 false, Y>3 false, z=9 false--cover path: F-f
    • (X=1. y=4,z=0)--x=1 True, Y>3 true, z=9 false--coverage path: t-f
Supplement:
Basic Path test method:
(1) Program Flowchart
The flowchart for the example above is:


(2) Calculate the complexity of the program loop.
    • V (G) = number of regions. A region is made up of shapes surrounded by boundaries and nodes. Contains the outer area of the diagram as a region when the area is calculated. So there are 3 regions, that is, there are 3 basic paths.
    • V (G) = number of boundaries-number of nodes +2. So V (G) = 6-5 + 2 = 3.

    • V (G) = number of inferred nodes + 1. The inferred nodes are a and C, so V (G) = 2 + 1 = 3--is generally used as the complexity of the loop . The cyclomatic complexity is the upper limit of the number of paths, and here's a look at the basic path.
(3) determine the basic path.
The program you see has 3 basic paths. The following is a basic set of paths:
    • A-c-end
    • A-b-c-end
    • A-b-c-d-end
? What the basic path is, how the 3 basic paths are drawn (why there are 3, choose the principle of the 3).

wish to know the friends leave a comment:)

The basic method of software testing (II.) white box test

Related Article

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.