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


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

    xmind版本 23.0911172

    • 标记打开位置
      在这里插入图片描述

    • 标记规则如下
      在这里插入图片描述
      解释:

        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 其它符号标  
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 完整代码如下
    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)
    
    • 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
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
  • 相关阅读:
    情人节程序员用HTML网页表白【我永远属于你】 HTML5七夕情人节表白网页源码 HTML+CSS+JavaScript
    C++中的static变量
    【C++】队列来喽,真的很简单的
    go工具-显示磁盘使用情况的工具diskusage
    【计算机毕业设计】75.教师工作考核绩效管理系统源码
    HashMap底层详讲
    SpringMVC学习|Servlet回顾、理解SpringMVC小demo、SpringMVC原理
    C#对象序列化
    拉格朗日粒子扩散模式FLEXPART,在大气污染溯源中的应用
    UAS协议说明
  • 原文地址:https://blog.csdn.net/weixin_44259638/article/details/134271709