Black box test case design-improvement of boundary value division ideas

table of Contents

Foreword:

Use case description:

to sum up:


Foreword:

In software testing, when designing use cases, black box test case design is a very common software testing idea.

The boundary value division idea is also a very common method for black box test case design.

The following are my thoughts on the boundary value division in work.

Use case description:

主流边界值划分思想为5个点就够了例如:[0,100]  -1,0,50,100,101

工作中发现5点划分存在不足,见如下代码:
# case1:[0,100]  -1,0,50,100,101 ==》合适
x = 3
if 0 <= x <= 100:
    print('True')
else:
    print('False')
# case2:[0,100]  -1,0,50,100,101 ==》合适
x = 300
if 0 <= x <= 100:
    print('True')
elif x < 0 or x > 100:
    print('False')
# case3:[0,100]  -1,0,50,100,101 ==》危险
if 0 <= x <= 100:
    print('True')
elif x <= -1 or x >= 101:
    print('False')
# case3:[0,100]  -1,0,50,100,101 ==》不适用
# 若错误把x <= -1 or x >= 101写成了 x == -1 or x == 101、x == -1 or x >= 101、x =< -1 or x == 101
# 这个时候用-1,0,50,100,101来测试依然是发现不出问题的
if 0 <= x <= 100:
    print('True')
elif x == -1 or x == 101:
    print('False')
# case4:[0,100]  -1,0,50,100,101 ==》不适用
# 若错误把x <= -1 or x >= 101写成了 x == -1 or x == 101、x == -1 or x >= 101、x =< -1 or x == 101
# 这个时候用-1,0,50,100,101来测试依然是发现不出问题的
if x == -1 or x == 101:
    print('False')
elif :
    print('True')

to sum up:

Therefore, I personally feel that the most secure is to take a 7-point test: -5, -1,0,50,100,101,105;

When writing code with if, there must be a corresponding else behind, which can increase the robustness of the code (when working at Sangfu, this is very important to the code specification and code review)

 

 

Guess you like

Origin blog.csdn.net/chuancheng_zeng/article/details/115109569