Technology Sharing | Black Box Testing Methodology - Boundary Value

Boundary value analysis is a very practical black box test case method, which has a strong ability to find faults. The boundary value analysis method is also used as a supplement to the equivalence class division method, and the test cases come from the boundary of the equivalence class.
This method is actually found in testing practice, bugs often appear on the boundary of the definition domain or value range, rather than inside it. Designing test cases specifically for processing near the detection boundary often yields good test results.
When the boundary value analysis method is used, the scene of the value range and the number of values ​​is generally specified.
When analyzing equivalence class cases and dividing equivalence classes, there are generally special points called poles or upper points. For example, the upper points in [1,100] are 1 and 100. These two values ​​are called boundary values ​​or extreme values. When designing test cases, you can focus on verifying its boundary points on the basis of equivalence classes.

Boundary value example

For example, the requirement in the requirement is that the input parameter value must be an integer greater than or equal to 0 and less than 100.
The correct code can set the judgment condition like this:

# 正确条件 1
num > -1 and num < 100
# 正确条件 2
num >= 0 and num <= 99

However, in the actual code writing process, it is very likely that the judgment condition is set incorrectly due to various reasons:

# 错误条件 1
num >= -1 and num <= 101
# 错误条件 2
num > 0 and num < 101
# 错误条件 3 
num >= 1 and num <= 100

The first error case is due to the inclusion of -1 and 101, the second error case is that 0 is either omitted, and the third error case is that 0 is omitted and 100 is included.
Because there will be various error conditions, it is necessary to select the boundary value and focus on testing to avoid these conditions.

Boundary value determination

Designing a use case using boundary value analysis requires a choice of 3 points to consider.

  • Upper point: point on the boundary
    • From point: The point closest to the upper point. If the input domain is closed, the off-point is outside the domain; if the input domain is an open interval, the off-point is within the domain.
    • Interior point: any point within the input field
  • To select just equal to, just greater than or just less than the boundary value as the test data, generally speaking, the upper point, the departure point and the inner point should be taken. So choose just equal to, just greater than or just less than the boundary value as the test data.
    To sum up, there are six points to be selected in the question: 0 and 100 which are exactly equal to the boundary value, -1 and 99 which are just less than the boundary value, and 1 and 101 which are just larger than the boundary value.

Boundary point division rules

1. If the value range of the input domain is specified, select points just on the boundary of the range and points just beyond the boundary as the input data for the test.
2. If the number of input values ​​is specified, use the maximum number, the minimum number, the number less than the minimum number by 1, and the number greater than the maximum number by 1 as the test data.
3. If it is specified that the input is an ordered set, select the first and last elements of the set as test data.
Note that the type and precision of the data need to be considered when choosing an off point. For example, the data type of the upper point is a real number and the precision is 0.001, then the off point is the upper point minus 0.001 or the upper point plus 0.001.

example

Problem: Calculate the sum of integers from 1 to 100 (including 1 and 100)
. The test cases that have been designed by the equivalence class method above are now supplemented by the boundary value analysis method.

The boundary values ​​are analyzed first: 1, 100 (valid equivalence class), followed by the values ​​on either side of the boundary value: 0, 2, 99, 101 (0 and 101 are invalid equivalence classes, 2 and 99 are valid equivalence classes).

Change the values ​​in the valid equivalence classes to boundary values. There are 4 valid equivalence class values ​​to be taken, which are 1, 2, 99, and 100. Then these four values ​​need to be taken in both input boxes. The invalid equivalence class also covers the two values ​​0 and 101, and the same two input boxes need to be covered.

Boundary Value Summary

When supplementing test cases with the boundary value method, pay attention to determine the boundary conditions (the boundary of the input or output equivalence class), select just equal to, just greater than or just less than the boundary value as the test data and determine the equivalence class of each value, The difference between boundary value and equivalence class is clearly defined, that is, boundary value analysis does not randomly select one from an equivalence class as a representative, but each boundary of this equivalence class should be used as a test condition.

Original link

More technical articles to share

Guess you like

Origin blog.csdn.net/hogwarts_2022/article/details/124255426