Soft test-Software Engineering-Test 2

Source: Internet
Author: User

The following is an example to illustrate the six coverage methods in the white box test: Statement overwrite, decision overwrite, condition overwrite, decision condition overwrite, condition combination overwrite, and path overwrite.

Objective of white-box testing: to overwrite the logic path in the software by checking the internal logic structure of the software; to set up checkpoints in different places of the program and check the program status, to determine whether the actual running status is consistent with the expected status.

White-box testing features: Testing Based on the software design specification, strict inspection of internal program details, design test cases for specific conditions, and coverage testing of the software's logical path.

Implementation steps of white box testing:

1. Test plan stage: Develop the test progress according to the requirement specification.
2. Test Design Phase: divide the software structure and design test cases according to the program design specification according to certain standardized methods.
3. test execution phase: Enter the test case to obtain the test result.
4. Test Summary stage: Compare the test results with the expected results of the Code, analyze the cause of the error, and locate and solve the error.

Advantages and disadvantages of white box testing

1. Advantages

· Forces testers to think carefully about software implementation
· Detect every branch and path in the code
· Uncover hidden errors in code
· Complete code Testing
· Optimization

2. Disadvantages

· Expensive
· Failure to detect missing paths and data sensitivity errors in the code
· Do not verify the correctness of specifications

Example:

 

1. Statement Overwrite

1) main features: statement coverage is the minimum structure coverage requirement. statement coverage requires the design of enough test cases so that each statement in the program can be executed at least once.

2) Use Case Design: (if the statement 1-> T in path a is removed, the use case is as follows)

X

Y

Path

1

50

50

Obde

2

90

70

Obce

3) Advantages: You can obtain test cases from the source code without dividing each judgment expression.

4) Disadvantages: This test method is only applicable to statements explicitly in the program logic. However, it cannot be tested for hidden conditions and potential Implicit logical branches. In this example, if the statement 1-> T is removed, a test path is missing. In the if structure, if the source code does not provide the Execution Branch after else, the statement overwrite test will not consider this situation. However, it cannot be ruled out that the branches other than this type will not be executed, and such errors often occur. For another example, in the do-while structure, the statement overwrites one of the conditional branches for execution. Obviously, statement overwrite cannot fully reflect the logic operation of multiple branches. It only cares about running once, regardless of other situations.

2. Decision coverage

1) main features: Decision coverage, also known as branch coverage, requires the design of enough test cases to make each decision in the program at least one true value and one false value, that is: each branch in the program must be executed at least once. Each true or false judgment must be performed at least once.

2) Use Case Design:

 

X

Y

Path

1

90

90

Oae

2

50

50

Obde

3

90

70

Obce

3) Advantage: The test path that overwrites the statement is almost twice as much as that of the statement. Of course, the test path is more powerful than the statement overwrites. Similarly, the overwrite method has the same simplicity as the overwrite method. You can obtain test cases without dividing each criterion.

4) Disadvantages: Most judgment statements are usually composed of multiple logical conditions (for example, the judgment statement contains and, or, and Case). If only the final result is determined, ignoring the values of each condition will inevitably omit some test paths.

3. Conditional coverage

1) main features: Condition coverage requires the design of enough test cases, so that each condition in the determination can obtain various possible results, that is, each condition is at least one true value, and one is a false value.

2) Use Case Design:

 

X

Y

Path

1

90

70

OBC

2

40

70

OBD

3) Advantage: Obviously, the coverage ratio of the condition is higher than the coverage ratio, and the test path is added.

4) Disadvantages: sufficient test cases are required to achieve the coverage of conditions, but the coverage of conditions cannot be guaranteed. Conditional overwrite only ensures that each condition is true at least once, regardless of all judgment results.

4. Decision/condition coverage

1) main features: Design enough test cases to make all possible results of each condition appear at least once, and all possible results of each criterion also appear at least once.

2) Use Case Design:

 

X

Y

Path

1

90

90

Oae

2

50

50

Obde

3

90

70

Obce

4

70

90

Obce

3) Advantages: the decision/condition coverage meets the decision coverage criteria and condition coverage criteria, making up for the shortcomings of both.

4) Disadvantages: the disadvantage of the criterion for determining/covering conditions is the combination of conditions not considered.

5. combined coverage

1) main features: a sufficient number of test cases must be designed to make all possible combinations of conditions in each decision appear at least once.

2) Use Case Design:

 

 

 

X

Y

Path

1

90

90

Oae

2

90

70

Obce

3

90

30

Obde

4

70

90

Obce

5

30

90

Obde

6

70

70

Obde

7

50

50

Obde

3) Advantages: the multi-condition coverage criteria meet the criteria for determining coverage, conditional coverage, and decision/condition coverage. The modified judgment/condition overwrite requires that a sufficient number of test cases be designed, so that all possible results of each condition in the determination appear at least once, and all possible results of each decision itself also appear at least once. In addition, each condition is shown to affect the judgment result separately.

4) Disadvantage: the number of test cases is linearly increased.

6. Path coverage

1) main features: Design enough test cases to cover all possible paths in the program.

2) Use Case Design:

 

X

Y

Path

1

90

90

Oae

2

50

50

Obde

3

90

70

Obce

4

70

90

Obce

3) Advantages: This test method can thoroughly test the program, which is wider than the previous five methods.

4) Disadvantages: Because Path coverage requires testing all possible paths (including loops, condition combinations, and Branch selection), a large number of complex test cases need to be designed, this increases the workload exponentially. In some cases, some execution paths cannot be executed, such:
If (! A) B ++;
If (! A) d --;

White-box testing is a widely used logic testing method and a unit testing method driven by the internal logic of the program. Only with a good understanding of the program can we conduct a moderately effective white box test. However, there is uncertainty and infinity in the logic throughout the program, especially for large-scale complex software. Therefore, we cannot trace all the logical paths, even if we do not, it may not bring good luck (we cannot identify program logic rule errors, data errors, or program missing paths ).

To correctly use the white-box test, you must first start with code analysis and select an appropriate override method based on different code logic rules and statement execution conditions. Any efficient test case is applicable to specific test scenarios. Logical testing does not mean one-sided testing of correct results or testing of incorrect results, but overwrites every logical path as much as possible.

 

 

 

 

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.