python+xmind,检查测试用例优先级

您所在的位置:网站首页 xmind音标怎么读 python+xmind,检查测试用例优先级

python+xmind,检查测试用例优先级

2024-01-30 12:22| 来源: 网络整理| 查看: 265

xmind是画思维脑图很好的工具,我们测试用例编写的常用工具

1.优先级规则

1.末级节点不能标优先级;

2.某节点有子节点且该子节点为末级节点,应标优先级;

3.某节点有子节点但该子节点非末级节点,不能标优先级。

2.优先级检查

python官方有解析xmind的库

安装xmind模块

pip install xmind

比如我们拿到一份测试用例,如果用例数目庞大,那么人工检查会相当麻烦

测试用例demo:

检测脚本如下,check.py

脚本设计方法深度优先遍历,算法简介:

深度优先遍历的非递归的通用做法是采用栈对每一个可能的分支路径深入到不能再深入为止,而且每个节点只能访问一次(二叉树的深度优先遍历比较特殊,可以细分为先序遍历,中序遍历,后序遍历)不全部保留节点,占用空间少,有回溯操作(即有入栈,出栈操作),运行速度慢。不全部保留节点,扩展完的结点从数据库中弹出删去,这样,一般在数据库中存储的结点数就是深度值,因此它占用的空间较少。 import sys import xmind # 当前节点不含有子节点为末级节点,不应设置优先级 unnecessary = '优先级多余' # 当前节点有儿子节点为末级节点,必须设置优先级 missing = '优先级缺失' current_path = [] unnecessary_cnt = 0 missing_cnt = 0 def check(node): current_path.append(node.getTitle()) has_end_node = if_has_end_node(node) has_priority = if_has_priority(node) is_end_node = if_end_node(node) global unnecessary_cnt, missing_cnt # 优先级多余 if (not has_end_node) and has_priority: print(unnecessary, '\t', '节点路径:', '/'.join(current_path)) unnecessary_cnt += 1 # 优先级缺失 if has_end_node and (not has_priority): print(missing, '\t', '节点路径:', '/'.join(current_path), ) missing_cnt += 1 if is_end_node: current_path.pop() else: for sub_topic in node.getSubTopics(): check(sub_topic) current_path.pop() def if_end_node(topic): if topic.getSubTopics(): return False else: return True def if_has_end_node(topic): if not if_end_node(topic): for sub_topic in topic.getSubTopics(): if if_end_node(sub_topic): return True return False def if_has_priority(topic): if topic.getMarkers(): for marker in topic.getMarkers(): markerId = marker.getMarkerId().name if markerId in ['priority-1', 'priority-2', 'priority-3', 'priority-4']: print(topic.getTitle(), ':', markerId) return True return False if __name__ == '__main__': workbook = xmind.load(sys.argv[1]) for sheet in workbook.getSheets(): rootTopic = sheet.getRootTopic() check(rootTopic) total_error_count = unnecessary_cnt + missing_cnt if total_error_count == 0: print("检查通过!") else: print("\n=================数据汇总=======================") print('错误总数:', total_error_count) print('优先级多余 %d 处' % unnecessary_cnt) print('优先级缺失 %d 处' % missing_cnt) 运行脚本 python check.py test.xmind

检查结果 无网络 : priority-2 网络超时 : priority-2 缓存路劲 : priority-1 /storage/emulated/0/Android/data/包名/files/Documents/Log.txt : priority-4 优先级多余 节点路径: 20220907/缓存路劲//storage/emulated/0/Android/data/包名/files/Documents/Log.txt as日志关键词过滤 : priority-3 手机,WIFi,断开网络 : priority-1 数据缓存成功,网络正常时上报成功 : priority-4 优先级多余 节点路径: 20220907/测试场景/手机,WIFi,断开网络/数据缓存成功,网络正常时上报成功 优先级缺失 节点路径: 20220907/测试场景/手机,WIFi,弱网,导致网络超时 模拟器,断开网络 : priority-1 模拟器,弱网,导致网络超时 : priority-1 手机,4g,断开网络 : priority-1 手机,4g,弱网,导致网络超时 : priority-1 手机,5g,断开网络 : priority-1 手机,5g,弱网,导致网络超时 : priority-1 =================数据汇总======================= 错误总数: 3 优先级多余 2 处 优先级缺失 1 处

这样多余和缺失的节点就一目了然了!



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3