python解析xmind统计测试用例/测试点 个数及执行情况

前言:统计的是每个分支最后一个节点的状态

xmind版本 23.0911172

  • 标记打开位置

  • 标记规则如下

    解释:

python 复制代码
    res = {"total": 0, "pass": 0, "fail": 0, "no_result": 0, "unfinished": 0, "now_fail": 0, "other": 0}
    # total= pass +  no_result+unfinished+ now_fail +other
    # total 用例总数
    #  pass 通过总数 含有"勾"的用例数
    # fail 失败总数 通过总数 含有"感叹号"的用例数
    # no_result 未进行任何标记 不含有任何标记的用例数
    # unfinished 未完成标记 含有"暂停"的用例数
    # now_fail 仍未通过 仅含有"感叹号"的用例数
    # other 其它符号标  
  • 完整代码如下
python 复制代码
from xmindparser import xmind_to_dict
import json

# 计算标记
def statistics(data):
    res["total"] = res["total"] + 1
    # 计算标记图案
    if data.get("makers"):
        # 至少一个标记
        if len(data["makers"]) >= 1:
            # 统计现在仍然只有失败标签的用例
            if len(data["makers"]) == 1 and data["makers"][0] == "symbol-exclam":
                res["now_fail"] = res["now_fail"] + 1
            # 遍历标记--所有图标
            for i in data["makers"]:
                if i == "task-done":
                    res["pass"] = res["pass"] + 1
                elif i == "symbol-exclam":
                    res["fail"] = res["fail"] + 1
                elif i == "task-start":
                    res["unfinished"] = res["unfinished"] + 1
                else:
                    res["other"] = res["other"] + 1
    else:  # 没有标记
        res["no_result"] = res["no_result"] + 1



def recursion(testcase):
    # 递归查询
    for i in testcase:
        if isinstance(i, dict):
            if i.get("topics") is None:
                statistics(i)
            else:
                recursion(i["topics"])
        else:
            recursion(i)


if __name__ == '__main__':
	# 路径
    out = xmind_to_dict(r"C:\Users\Administrator\Desktop\测试项目.xmind")
    test_case = out[0]["topic"]["topics"]
    res = {"total": 0, "pass": 0, "fail": 0, "no_result": 0, "unfinished": 0, "now_fail": 0, "other": 0}
    recursion(test_case)
    print(res)
相关推荐
HtwHUAT13 分钟前
实验四 Java图形界面与事件处理
开发语言·前端·python
Tech Synapse15 分钟前
基于Surprise和Flask构建个性化电影推荐系统:从算法到全栈实现
python·算法·flask·协同过滤算法
麦麦大数据17 分钟前
vue+flask+CNN电影推荐系统
pytorch·python·cnn·flask·scikit-learn·电影推荐
腾飞开源22 分钟前
02_Flask是什么?
python·flask·python web开发·flask快速入门教程·人人都能学·小白看得懂学得会·跟我学编程
終不似少年遊*22 分钟前
国产之光DeepSeek架构理解与应用分析04
人工智能·python·深度学习·算法·大模型·ds
明月看潮生30 分钟前
青少年编程与数学 02-016 Python数据结构与算法 28课题、图像处理算法
图像处理·python·算法·青少年编程·编程与数学
羊小猪~~1 小时前
深度学习基础--CNN经典网络之InceptionV3详解与复现(pytorch)
网络·人工智能·pytorch·python·深度学习·机器学习·cnn
深度学习lover1 小时前
<项目代码>YOLO小船识别<目标检测>
人工智能·python·yolo·目标检测·计算机视觉·小船识别
愚公搬代码2 小时前
【愚公系列】《Python网络爬虫从入门到精通》055-Scrapy_Redis分布式爬虫(安装Redis数据库)
数据库·爬虫·python
浅浅2803 小时前
numpy、pandas内存优化操作整理
数据结构·经验分享·python·学习·性能优化·numpy·pandas