zoukankan      html  css  js  c++  java
  • Java——xmind测试用例转excel格式(xmind格式解析)

    xmind内容主要结构是以json格式构成的,将.xmind文件后缀改成.zip,可以看见一个content.json文件,整个思维导图的内容及结构就在这个文件中。

    本小项目所用xmind用例模板如图:

    图标含义:

    1. 开始图标表示前置条件("markerId": "task-start")
    2. 数字图标表示用例及优先级("markerId": "priority-3")

    将其后缀改为.zip,打开可见一个content.json文件,里面即为xmind内容及组成结构:

     

     打开该文件,可以用JSON在线解析及格式化验证工具(https://www.json.cn/)格式化一下,方便观察结构组成:

    [
        {
            "id":"5aebd6f249aa3e09c508bba69b",
            "class":"sheet",
            "title":"画布 1",
            "rootTopic":{
                "id":"b9aa22deba98b3b20c7ac8aca2",
                "class":"topic",
                "title":"根目录,不导入",
                "structureClass":"org.xmind.ui.map.unbalanced",
                "children":{
                    "attached":[
                        {
                            "id":"b58888b5ceebbf0e68dada0656",
                            "title":"模块1",
                            "children":{
                                "attached":[
                                    {
                                        "id":"86d91b46-78b0-4be0-adc5-28c5de6d1176",
                                        "title":"这是前置条件,前面需要加图标",
                                        "markers":[
                                            {
                                                "markerId":"task-start"
                                            }

                                        ]
    ,
                                        "children":{
                                            "attached":[
                                                {
                                                    "id":"c6100b2e-1a29-490d-920c-4514a2bc96d8",
                                                    "title":"这是用例名,需要加图标1-4",
                                                    "markers":[
                                                        {
                                                            "markerId":"priority-3"
                                                        }

                                                    ]
    ,
                                                    "children":{
                                                        "attached":[
                                                            {
                                                                "id":"31edfe34-d973-404e-bde3-6ce06c82882f",
                                                                "title":"步骤1",
                                                                "children":{
                                                                    "attached":[
                                                                        {
                                                                          "id":"5851a9b0-5546-4e58-a4a8-2bf535feb2fc",
                                                                          "title":"结果1"
                                                                        }

                                                                    ]

                                                                }

                                                            }
    ,
                                                            {
                                                                "id":"7fcce725-a816-4831-92a2-2996c5285124",
                                                                "title":"结果2"
                                                            }
    ,
                                                            {
                                                                "id":"fec20ab8-caec-4bd0-a41e-e35c13e9354b",
                                                                "title":"步骤3",
                                                                "children":{
                                                                    "attached":[
                                                                        {
                                                                          "id":"c3c53f4e-4299-47dc-b2a1-844a3a878b15",
                                                                          "title":"结果3"
                                                                        }

                                                                    ]

                                                                }

                                                            }

                                                        ]

                                                    }

                                                }
    ,
                                                {
                                                    "id":"7e730e6c-be56-4397-abcc-f58833441ce4",
                                                    "title":"这是用例名2",
                                                    "markers":[
                                                        {
                                                            "markerId":"priority-2"
                                                        }

                                                    ]
    ,
                                                    "children":{
                                                        "attached":[
                                                            {
                                                                "id":"4a8b8fe8-ac98-4d14-abe6-8e522492a86a",
                                                                "title":"步骤1&结果1"
                                                            }
    ,
                                                            {
                                                                "id":"9f5c6a48-c4c2-45b8-b9e2-51df29015fb3",
                                                                "title":"步骤2&结果2"
                                                            }
    ,
                                                            {
                                                                "id":"2d53504f-e658-4060-8507-ed90b04a9419",
                                                                "title":"结果",
                                                                "titleUnedited":true
                                                            }

                                                        ]

                                                    }

                                                }

                                            ]

                                        }

                                    }
    ,
                                    {
                                        "id":"11988da4-2a01-4d2c-b8e6-4de49998779f",
                                        "title":"模块1-1",
                                        "children":{
                                            "attached":[
                                                {
                                                    "id":"a7289a52-ac9f-48ba-a1ce-9fa86dd10010",
                                                    "title":"/模块1-1用例没有前置条件",
                                                    "markers":[
                                                        {
                                                            "markerId":"priority-1"
                                                        }

                                                    ]
    ,
                                                    "children":{
                                                        "attached":[
                                                            {
                                                             "id":"c32ad9cc-f68e-4373-9b70-77dc92177a14",
                                                             "title":"步骤1",
                                                             "children":{
                                                                 "attached":[
                                                                     {
                                                                         "id":"22136d6c-dc41-46f9-a601-8c1868eaed69",
                                                                         "title":"结果1"
                                                                                         }

                                                                                    ]

                                                                }
    ,
                                                                "titleUnedited":true
                                                            }

                                                        ]

                                                    }

                                                }
    ,
                                                {
                                                 "id":"7aaaaeaf-103c-46dc-8163-b6ba069f61cb",
                                                 "title":"模块1-1用例,没有步骤和结果",
                                                 "markers":[
                                                        {
                                                            "markerId":"priority-3"
                                                        }

                                                               ]

                                                }
    ,
                                                {
                                                    "id":"63574e0d-9597-42af-9f2c-3ad987682281",
                                                    "title":"模块1-1用例只有结果",
                                                    "markers":[
                                                        {
                                                            "markerId":"priority-2"
                                                        }

                                                    ]
    ,
                                                    "children":{
                                                        "attached":[
                                                            {
                                                             "id":"9e1c42ed-f948-41b5-b993-2e768f976625",
                                                             "title":"结果1"
                                                            }
    ,
                                                            {
                                                             "id":"05ec053e-77e5-4e6a-91f4-d5992a85e737",
                                                             "title":"结果1"
                                                            }

                                                        ]

                                                    }

                                                }

                                            ]

                                        }

                                    }

                                ]

                            }

                        }
    ,
                        {
                            "id":"193b56735e689ae86a01d91513",
                            "title":"模块2",
                            "children":{
                                "attached":[
                                    {
                                      "id":"0f6c8c6d-5bb5-4536-94ba-cdbedbca149e",
                                      "title":"这是前置条件,前面需要加图标",
                                      "markers":[
                                            {
                                                "markerId":"task-start"
                                            }

                                                 ]
    ,
                                        "children":{
                                            "attached":[
                                                {
                                                  "id":"637a8703-0633-45c9-83ff-ec49513c7e6e",
                                                  "title":"/模块2用例1",
                                                  "markers":[
                                                        {
                                                            "markerId":"priority-2"
                                                        }

                                                                 ]
    ,
                                                    "children":{
                                                        "attached":[
                                                            {
                                                              "id":"a061a8f2-8d38-4213-9399-ea3913e25feb",
                                                              "title":"步骤1&结果1"
                                                            }
    ,
                                                            {
                                                                "id":"a8f06d8e-801d-4acd-9ae2-01b99e7fb63e",
                                                                "title":"步骤2&结果2"
                                                            }

                                                        ]

                                                    }

                                                }

                                            ]

                                        }
    ,
                                        "titleUnedited":true
                                    }

                                ]

                            }

                        }

                    ]

                }
    ,
                "extensions":[
                    {
                        "content":[
                            {
                                "content":"2",
                                "name":"right-number"
                            }

                        ]
    ,
                        "provider":"org.xmind.ui.map.unbalanced"
                    }

                ]

            }
    ,
            "theme":{
                (此处省略展示具体样式信息)
            }
    ,
            "topicPositioning":"fixed"
        }

    ]

      所以我们要做的就是解析这个json文件然后拿到相应节点的内容填充到相应的excel单元格当中,可以看出文本类容主要集中在title标签中,xmind的json路径比较深,没有做标记的话不好区分,俗话说没有规矩不成方圆,所以我们需要定义xmind用例的格式这样才好去解析它。

  • 相关阅读:
    IndexedDB demo showcase
    javascript for
    IndexedDB
    web sql Database
    webSql
    哈哈 代表月亮
    网易
    Android 百度地图 SDK v3.0.0 (一)
    iOS使用Instrument的Leaks查找代码内存泄露
    换主页轮播的主题图片(4、删除)---轻开电子商务系统(企业入门级B2C站点)
  • 原文地址:https://www.cnblogs.com/huie/p/13516047.html
Copyright © 2011-2022 走看看