Software Test Basic method (b) White box test _ Software 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 product internal action in accordance with the requirements of the design specifications of the normal, inspection procedures in each of the access to the correct requirements of the work.


Category: White-box testing is based on coverage of the test, as much as possible to cover the structure of the program and logical path, so its specific methods are logical coverage, circular coverage, basic path coverage. Logical coverage can be further divided into statement coverage, decision (branch) coverage, condition coverage, judgment-condition coverage, conditional combination coverage, etc. White box testing is mainly used for unit testing (we need to understand the source and structure of the program, and based on input and output, suitable for the unit module). The following focuses on several commonly used white-box testing methods.


Statement overrides:

Definition: As long as you want to overwrite all executable statements (at least once for each executable statement), do not pay attention to the judgment operation, make sure that the executable statement does not have errors.


Example:



With the white box, we just need to cover all the executable statements, and for that we just need to use test cases (x=1,y=4,z=9). Such three words will be printed out. However, if the encoding x=1 and y>3 error is written as X=1 OR y>3, our test case can overwrite all executable statements and prove that the executable statement is correct, but our password system is at great risk and Y can breach the first line of defense as long as it is greater than 3. And we don't know about it. So statement coverage does not meet our needs (some say it is the weakest logical coverage criterion).


Decision (branch) Overlay:

Definition: The Take-true branch of each judgment and the take-leave branch go through at least once. Make up for the inadequacy of statement coverage on judgment logic.


Example: Ditto.

(x=1,y=4,z=9)--Through Path t->t (x=0,y=4,z=0)--Through the path f->f the top two test cases, the two of the true and false values of the criteria are traversed, is the execution of a decision coverage of the least test cases. This allows the second test case to discover errors when X=1 and Y>3 are mistakenly written as X=1 OR y>3. However, if you choose a test case that is (x=0,y=0,z=0) or you cannot find an error. Try the following overlay.
Conditional override: Definition: Make each condition in each judgment at least one at a time.
Example: Ditto. There are two conditions x=1 and y>3 in the first judgment, and a condition z=9 in the second judgment. (x=1,y=4,z=9)--x=1 true, Y>3 True, Z=9 True (x=0,y=0,z=0)--x=1 false, Y>3 false, z=9 False is also two test cases can be. There are two problems with this coverage: still can't solve the or problem if the selected test case is (x=1,y=2,z=9) and (x=0,y=4,z=0), although eligible for coverage, the first judgment executes only the fake branch, which omits logic errors.
Judgment--Conditional coverage: definition: A combination of decision coverage and conditional coverage. Ensure that the true and false of each condition in each judgment is satisfied at least once, and that the true and false branches of each judgment are at least once.
Example: Ditto. (x=1,y=4,z=9) (x=0,y=0,z=0) so that every judge of the true and false branches are taken, but also to each judge of the true and false of each condition are also taken. But it does not solve the or problem-when and mistakenly written to or, the execution path of the two use cases is unchanged, so the two use cases alone are not aware of the error.
Conditional combination Coverage: definition: For each judgment, the combination of the true and false values of the conditions (if this judgment consists of two conditions, then should be designed t1t2, T1F2, f1t2, f1f2 such a combination), and let each judgment of the true and false values are taken.
Example: Ditto. (x=1,y=4,z=9)--x=1 true, Y>3 True, z=9 true--cover 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--Overwrite path: f-t
(x=0,y=0,z=0)--x=1 false, Y>3 false, z=9 false--cover path: F-f
When an or problem occurs, the path to the second to third use case is changed to detect errors. This solves the or problem, because one of the true and false combinations in the first judgment is the fundamental means of distinguishing between and and OR. Although the or problem was resolved, we found a path that did not cover the--t-f.
Path override: Definition: Overwrites all possible paths.
Example: Ditto. Let's modify the second use case on the basis of the conditional combination overwrite use case. (x=1,y=4,z=9)--x=1 true, Y>3 True, z=9 true--cover path: T-t (x=1,y=4,z=0)--x=1 true, Y>3 true, z=9 false--Overwrite path: t-f (x=0,y=4,z=9)--x=1 false,y> 3 True, 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 Although the path is covered, the path overlay does not cover all the conditional combinations.
Summarize:
There is no one overlay that can completely cover all test cases. Therefore, in the actual test case design, many kinds of coverage are often combined to achieve the highest coverage. In this case, the final test case 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--cover 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--Overwrite 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--cover path: T-f fill:
Basic Path test method:
(1) Program flow chart
The flowchart for the above example is:


(2) Calculating the complexity of the program loop. V (G) = number of regions. A region is composed of a shape surrounded by boundaries and nodes, which includes the outer region of the graph as an area. So the above image has 3 areas, that is, there are 3 basic paths. V (G) = number of boundaries-number of nodes +2. Such V (G) = 6-5 + 2 = 3. V (G) = judge the number of nodes + 1. The decision nodes in the above diagram are a and C, so V (G) = 2 + 1 = 3--generally uses it as the complexity of the loop, and the cyclomatic complexity is the upper limit of the number of paths, so let's look at the basic path. (3) determine the basic path.
The program shown above has 3 basic paths, and the following is a set of basic paths: A-c-end a-b-c-end a-b-c-d-end. What is the basic path, and how 3 basic paths are derived (why there are 3, select the principles of the 3). wish to know friends leave a comment:)

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.