玩转用例设计:XMind2TestCase一个高效的测试用例设计解决方案

发表于:2019-2-27 11:30

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:devinzhang    来源:掘金

  XMind2TestCase 工具,提供了一个高效测试用例设计的解决方案(开源)
  一、背景
  软件测试过程中,最重要、最核心就是测试用例的设计,也是测试童鞋、测试团队日常投入最多时间的工作内容之一。
  然而,传统的测试用例设计过程有很多痛点:
  1、使用Excel表格进行测试用例设计,虽然成本低,但版本管理麻烦,维护更新耗时,用例评审繁琐,过程报表统计难...
  2、使用TestLink、TestCenter、Redmine等传统测试管理工具,虽然测试用例的执行、管理、统计比较方便,但依然存在编写用例效率不高、思路不够发散、在产品快速迭代过程中比较耗时等问题...
  3、公司自研测试管理工具,这是个不错的选择,但对于大部分小公司、小团队来说,一方面研发维护成本高,另一方面对技术要有一定要求...
  4、...
  基于这些情况,现在越来越多公司选择使用思维导图这种高效的生产力工具进行用例设计,特别是敏捷开发团队。
  事实上也证明,思维导图其发散性思维、图形化思维的特点,跟测试用例设计时所需的思维非常吻合,所以在实际工作中极大提升了我们测试用例设计的效率,也非常方便测试用例评审。
  但是与此同时,使用思维导图进行测试用例设计的过程中也带来不少问题:
  1、测试用例难以量化管理、执行情况难以统计;
  2、测试用例执行结果与BUG管理系统难以打通;
  3、团队成员用思维导图设计用例的风格各异,沟通成本巨大;
  4、...
  综合以上情况,我们可以发现不同的测试用例设计方式,各有各个的优劣。
  那么问题来了,我们能不能将它们各自优点合在一起呢?这样不就可以提升我们的效率了!
  于是,这时候 XMind2TestCase 就应运而生了,该工具基于 Python 实现,通过制定测试用例通用模板,
  然后使用 XMind 这款广为流传且开源的思维导图工具进行用例设计。
  其中制定测试用例通用模板是一个非常核心的步骤(具体请看使用指南),有了通用的测试用例模板,我们就可以在 XMind 文件上解析并提取出测试用例所需的基本信息,
  然后合成常见测试用例管理系统所需的用例导入文件。这样就将 XMind 设计测试用例的便利与常见测试用例系统的高效管理结合起来了!
  当前 XMind2TestCase 已实现从 XMind 文件到 TestLink 和 Zentao(禅道) 两大常见用例管理系统的测试用例转换,同时也提供 XMind 文件解析后的两种数据接口
  (TestSuites、TestCases两种级别的JSON数据),方便快速与其他测试用例管理系统打通。
  二、使用示例
  1、Web工具示例
  2、转换后用例预览
  3、TestLink导入结果示例
  4、禅道(ZenTao)导入结果示例
  三、安装方式
 pip3 install xmind2testcase
  四、版本升级
 pip3 install -U xmind2testcase
  五、使用方式
  1、命令行调用
   Usage:
  xmind2testcase [path_to_xmind_file] [-csv] [-xml] [-json]
  Example:
  xmind2testcase /path/to/testcase.xmind        => output testcase.csv、testcase.xml、testcase.json
  xmind2testcase /path/to/testcase.xmind -csv   => output testcase.csv
  xmind2testcase /path/to/testcase.xmind -xml   => output testcase.xml
  xmind2testcase /path/to/testcase.xmind -json  => output testcase.json
  2、使用Web界面

   Usage:
  xmind2testcase [webtool] [port_num]
  Example:
  xmind2testcase webtool        => launch the web testcase convertion tool locally -> 127.0.0.1:5001
  xmind2testcase webtool 8000   => launch the web testcase convertion tool locally -> 127.0.0.1:8000
  3、API调用
   import json
  import xmind
  from xmind2testcase.zentao import xmind_to_zentao_csv_file
  from xmind2testcase.testlink import xmind_to_testlink_xml_file
  from xmind2testcase.utils import xmind_testcase_to_json_file
  from xmind2testcase.utils import xmind_testsuite_to_json_file
  from xmind2testcase.utils import get_xmind_testcase_list
  from xmind2testcase.utils import get_xmind_testsuite_list
  def main():
  xmind_file = 'docs/xmind_testcase_template.xmind'
  print('Start to convert XMind file: %s' % xmind_file)
  zentao_csv_file = xmind_to_zentao_csv_file(xmind_file)
  print('Convert XMind file to zentao csv file successfully: %s' % zentao_csv_file)
  testlink_xml_file = xmind_to_testlink_xml_file(xmind_file)
  print('Convert XMind file to testlink xml file successfully: %s' % testlink_xml_file)
  testsuite_json_file = xmind_testsuite_to_json_file(xmind_file)
  print('Convert XMind file to testsuite json file successfully: %s' % testsuite_json_file)
  testcase_json_file = xmind_testcase_to_json_file(xmind_file)
  print('Convert XMind file to testcase json file successfully: %s' % testcase_json_file)
  testsuites = get_xmind_testsuite_list(xmind_file)
  print('Convert XMind to testsuits dict data:\n%s' % json.dumps(testsuites, indent=2, separators=(',', ': '), ensure_ascii=False))
  testcases = get_xmind_testcase_list(xmind_file)
  print('Convert Xmind to testcases dict data:\n%s' % json.dumps(testcases, indent=4, separators=(',', ': ')))
  workbook = xmind.load(xmind_file)
  print('Convert XMind to Json data:\n%s' % json.dumps(workbook.getData(), indent=2, separators=(',', ': '), ensure_ascii=False))
  print('Finished conversion, Congratulations!')
  if __name__ == '__main__':
  main()
  4、XMind用例文件转为JSON数据
  (1)转为测试用例JSON数据
   from xmind2testcase.utils import get_xmind_testcase_list
  xmind_file = 'docs/xmind_testcase_demo.xmind'
  testcases = get_xmind_testcase_list(xmind_file)
  print(testcases)
  Output:
  [
  {                                                # 测试用例
  "name": "测试用例1",                           # 用例标题
  "version": 1,                                 # 用例版本
  "summary": "测试用例1",                        # 用例摘要
  "preconditions": "前置条件",                   # 前置条件
  "execution_type": 1,                          # 用例执行类型(1:手动、2:自动)
  "importance": 1,                              # 优先级(1:高、2:中、3:低)
  "estimated_exec_duration": 3,                 # 预计执行时间(分钟)
  "status": 7,                                  # 用例状态(1:草稿、2:待评审、3:评审中、4:重做、5、废弃、6:feature、7:终稿)
  "steps": [                                    # 测试步骤列表
  {
  "step_number": 1,                     # 编号
  "actions": "测试步骤1",                 # 步骤内容
  "expectedresults": "预期结果1",         # 预期结果
  "execution_type": 1                    # 执行类型(1:手动,2:自动)
  },
  {
  "step_number": 2,
  "actions": "测试步骤2",
  "expectedresults": "预期结果2",
  "execution_type": 1
  }
  ],
  "product": "我是产品名",                          # 产品名称
  "suite": "我是模块名(测试集1)"                     # 测试集(模块名)
  },
  {
  "name": "测试用例2",
  "version": 1,
  "summary": "测试用例2",
  "preconditions": "前置条件",
  "execution_type": 1,
  "importance": 1,
  "estimated_exec_duration": 3,
  "status": 7,
  "steps": [
  {
  "step_number": 1,
  "actions": "测试步骤1",
  "expectedresults": "预期结果1",
  "execution_type": 1
  },
  {
  "step_number": 2,
  "actions": "测试步骤2(预期结果2可以为空)",
  "expectedresults": "",
  "execution_type": 1
  },
  {
  "step_number": 3,
  "actions": "测试步骤3",
  "expectedresults": "预期结果3",
  "execution_type": 1
  },
  {
  "step_number": 4,
  "actions": "测试步骤4",
  "expectedresults": "预期结果4",
  "execution_type": 1
  }
  ],
  "product": "我是产品名",
  "suite": "我是模块名(测试集1)"
  },
  {
  "name": "测试用例3(测试步骤和预期结果可以都为空)",
  "version": 1,
  "summary": "测试用例3(测试步骤和预期结果可以都为空)",
  "preconditions": "无",
  "execution_type": 1,
  "importance": 2,
  "estimated_exec_duration": 3,
  "status": 7,
  "steps": [ ],
  "product": "我是产品名",
  "suite": "我是模块名(测试集1)"
  },
  {
  "name": "测试步骤2(优先级默认为中)",
  "version": 1,
  "summary": "测试步骤2(优先级默认为中)",
  "preconditions": "无",
  "execution_type": 1,
  "importance": 3,
  "estimated_exec_duration": 3,
  "status": 7,
  "steps": [
  {
  "step_number": 1,
  "actions": "测试步骤1",
  "expectedresults": "预期结果1",
  "execution_type": 1
  },
  {
  "step_number": 2,
  "actions": "测试步骤3",
  "expectedresults": "",
  "execution_type": 1
  }
  ],
  "product": "我是产品名",
  "suite": "我是模块名(测试集2)"
  },
  {
  "name": "测试用例3(前置条件默认为空) 无设置优先级,这里加入用例标题",
  "version": 1,
  "summary": "测试用例3(前置条件默认为空) 无设置优先级,这里加入用例标题",
  "preconditions": "无",
  "execution_type": 1,
  "importance": 2,
  "estimated_exec_duration": 3,
  "status": 7,
  "steps": [ ],
  "product": "我是产品名",
  "suite": "我是模块名(测试集2)"
  }
  ]
  
       上文内容不用于商业目的,如涉及知识产权问题,请权利人联系博为峰小编(021-64471599-8017),我们将立即处理。
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号