有函数f(x,y,z)=x+y2-z,其中x∈[2000,3000],y∈[1,9],z∈[10,30]的。请写出该函数采用13个用例的边界值分析法、健壮性分析法、最坏情况测试分析法设计的测试用例。并编写程序
时间: 2024-02-09 21:08:25 浏览: 54
测试用例的边界值分析法
边界值分析法:
1. x = 2000, y = 1, z = 10
2. x = 2000, y = 1, z = 30
3. x = 2000, y = 9, z = 10
4. x = 2000, y = 9, z = 30
5. x = 3000, y = 1, z = 10
6. x = 3000, y = 1, z = 30
7. x = 3000, y = 9, z = 10
8. x = 3000, y = 9, z = 30
9. x = 2500, y = 1, z = 10
10. x = 2500, y = 1, z = 30
11. x = 2500, y = 9, z = 10
12. x = 2500, y = 9, z = 30
13. x = 2500, y = 5, z = 20
健壮性分析法:
1. x = 1999, y = 0, z = 9
2. x = 3001, y = 10, z = 31
3. x = 2500, y = 10, z = 20
4. x = 2500, y = 0, z = 20
最坏情况测试分析法:
1. x = 2000, y = 1, z = 30
2. x = 2000, y = 9, z = 10
3. x = 3000, y = 1, z = 30
4. x = 3000, y = 9, z = 10
5. x = 2500, y = 1, z = 30
6. x = 2500, y = 9, z = 10
7. x = 2000, y = 5, z = 20
8. x = 3000, y = 5, z = 20
9. x = 2500, y = 1, z = 20
10. x = 2500, y = 9, z = 20
下面是 Python 代码实现,可以复制到 Python 环境中直接运行:
```python
def f(x, y, z):
return x + y ** 2 - z
# 边界值分析法
test_cases = [
[2000, 1, 10],
[2000, 1, 30],
[2000, 9, 10],
[2000, 9, 30],
[3000, 1, 10],
[3000, 1, 30],
[3000, 9, 10],
[3000, 9, 30],
[2500, 1, 10],
[2500, 1, 30],
[2500, 9, 10],
[2500, 9, 30],
[2500, 5, 20]
]
print("边界值分析法测试结果:")
for i, tc in enumerate(test_cases):
x, y, z = tc
result = f(x, y, z)
print(f"测试用例{i+1}: x={x}, y={y}, z={z}, result={result}")
# 健壮性分析法
test_cases = [
[1999, 0, 9],
[3001, 10, 31],
[2500, 10, 20],
[2500, 0, 20]
]
print("健壮性分析法测试结果:")
for i, tc in enumerate(test_cases):
x, y, z = tc
result = f(x, y, z)
print(f"测试用例{i+1}: x={x}, y={y}, z={z}, result={result}")
# 最坏情况测试分析法
test_cases = [
[2000, 1, 30],
[2000, 9, 10],
[3000, 1, 30],
[3000, 9, 10],
[2500, 1, 30],
[2500, 9, 10],
[2000, 5, 20],
[3000, 5, 20],
[2500, 1, 20],
[2500, 9, 20]
]
print("最坏情况测试分析法测试结果:")
for i, tc in enumerate(test_cases):
x, y, z = tc
result = f(x, y, z)
print(f"测试用例{i+1}: x={x}, y={y}, z={z}, result={result}")
```
阅读全文