Writing in the front

This is a five-minute test column, designed to share the knowledge of software testing, will be updated from time to time serials, everyone pay attention to ~

If my article can help you a little bit, I will be very happy, and please remember to give me a thumbs up

An example

Using a simple addition function as an example of boundary value analysis, the program requirements specification is simple as follows:

  • For valid input, the function returns the sum of x1 and x2
  • For invalid input, the function returns -1
def add (x1, x2):
    if 1<=x1<=200 and 50<=x2<=300:
        return x1 + x2
    else:
        return -1Copy the code

Boundary value analysis

1. Basic concepts

Boundary value analysis method is a black box test method to test the boundary value of input or output. It is a supplement to equivalence class partition method, and its test design is based on equivalence class partition method. The basic idea is to validate the system by taking input variable values at minimum, slightly above minimum, normal, maximum, and slightly below maximum. Experience shows that a large number of defects occur at the boundary values of input and output, not at the range values of input and output.

2. Principle of boundary value analysis for test case design

(1) If the input conditions specify the range of values, the boundary values just reaching this range and those just exceeding this range should be taken as the test input data. (2) If the input conditions specify the number of values, the maximum number, the minimum number and the number 1 more than the maximum number and 1 less than the minimum number are used as test data. (3) According to the program specification for each output condition, the principle of use (1). (4) According to the program specifications for each output condition, use principle (2). (5) If the input field or output field given in the program specification is an ordered set (such as an ordered table, a sequential file, etc.), the first and last elements in the set should be selected as test cases. (6) If an internal data structure is used in the program, the values on the boundaries of the internal data structure should be selected as test cases. (7) Analyze program specifications to identify other possible boundary conditions.

3. Design steps of boundary value analysis

3.1 Determine input conditions and boundary points

The boundary can be obtained by finding the boundary point of each input condition

There are two input conditions in the addition function:

(1) < = 1 x1 < = 200

X1 can determine two boundary points (1 and 200), values a little smaller than the boundary points (0 and 199), and values a little larger than the boundary points (2 and 201). Finally, x1 input conditions confirm that there are six test data: 0, 1, 2, 199, 200,201

(2) < = 50 x2 < = 300

X2 can determine two boundary points (50 and 300), values a little smaller than the boundary points (49 and 299), and values a little larger than the boundary points (51 and 301). Finally, the X2 input criteria confirm that there are six test data: 49, 50, 51, 299,300,301

3.2 Test case design

Test cases are designed based on the single-boundary principle, that is, test cases are designed for each boundary point and domain test data. For example, x1 boundary point 1 and domain data are 0 and 2, 3 test cases can be designed. The above input conditions have 4 boundary points, and the following 12 test cases can be designed in total

Serial number x1 x2 The expected output

1

0 200 – 1
2

1

200 201
3 2 200 202
4 199 200 399
5 200 200 400
6 201 200 – 1
7 100 49 – 1
8 100 50 150
9 100 51 151
10 100 299 399
11 100 300 400
12 100 301 – 1

4. Boundary value analysis of output results

As mentioned in the basic concept, boundary value analysis is a black box test method to test the boundary value of the input or output. So let me illustrate how to perform boundary value analysis on the output. For example, the performance evaluation of a test team has the following rules:

  • A High defect was found with a weight of 3
  • A Middle defect is found with a weight of 2
  • A Low defect was found with a weight of 1

The total score [0,60] is C, the total score [60,80] is B, and the total score [80,100] is A. Assuming that the total score exceeds 100, it is considered invalid

4.1 Determine the output results and boundary points

The performance ABC and invalidity of the four output results can be determined, and the four boundary points can be determined as: 0,60,80 and 100 respectively

Based on single boundary value design principles, can design 11 boundary value: 0,1,59,60,61,79,80,81,99,100,101

4.2 Designing Test Cases

The input values can be combined at will, as long as the output is achieved

Serial number Low (1) M (2) High (3) score The expected output
1 0 0 0 0 C
2 1 0 0 1 C
3 10 20 3 59 C
4 11 20 3 60 B
5 12 20 3 61 B
6 30 20 3 79 B
7 31 20 3 80 A
8 32 20 3 81 A
9 0 0 33 99 A
10 1 0 33 100 A
11 2 0 33 101 invalid

Stay tuned to the 5 Minute Quiz for the latest original articles

Author: Five minutes to say the test

This paper links: blog.csdn.net/LeechengLov…