测试作业1-组合分析方法

测试作业1-组合分析方法

正交法代码实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from allpairspy import AllPairs

def is_valid_combination(row):
n = len(row)
# 设置过滤条件
if n > 2:
# ⼀年级 不能匹配 10-13岁
if "未登录" == row[0] and "⾮会员" != row[1]:
return False
if "第⼀次登录" == row[0] and "VIP会员" == row[1]:
return False
if "会员" == row[1] and "会员9折" != row[2]:
return False
if "VIP会员" == row[1] and "VIP会员8折" != row[2]:
return False
return True
parameters = [
["未登录", "第⼀次登录", "正常登录"],
["⾮会员", "会员", "VIP会员", "雇员"],
["没有", "假⽇95折", "会员9折","VIP会员8折"],
["标准", "快递", "加急"]
]
print("PAIRWISE:")
for i, pairs in enumerate(AllPairs(parameters,filter_func=is_valid_combination)):
print("⽤例编号{:2d}: {}".format(i, pairs))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from allpairspy import AllPairs

# 因子水平
parameters = [
["未登录", "第⼀次登录", "正常登录"],
["⾮会员", "会员", "VIP会员", "雇员"],
["没有", "假⽇95折", "会员9折","VIP会员8折"],
["标准", "快递", "加急"]
]

# 实现约束的函数
def constraint_func(row):
n = len(row)
if n > 2:
if "未登录" == row[0] and "⾮会员" != row[1]:
return False
if "第⼀次登录" == row[0] and "VIP会员" == row[1]:
return False
if "会员" == row[1] and "会员9折" != row[2]:
return False
if "VIP会员" == row[1] and "VIP会员8折" != row[2]:
return False
return True

# print("PAIRWISE:")
# 输出结果
for i, pairs in enumerate(AllPairs(parameters,filter_func=constraint_func)):
print("⽤例编号{:2d}: {}".format(i, pairs))
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2023-2024 Guijie Wang
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信