超详细xmind2testcase安装与使用规则
Posted 奋斗de陈哆肉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了超详细xmind2testcase安装与使用规则相关的知识,希望对你有一定的参考价值。
目录
3.在命令提示符下输入:xmind2testcase webtool 8000
1.一定要用xmind-8-update9-windows制作用例
5.用例步骤、预期结果序号后多一个空格,修改zentao.py
6.每导出一个用例步骤和预期结果都会多一个换行符,修改zentao.py
一、安装python环境
1.配置Python所需环境
超详细Python安装教程_陈哆肉de博客-CSDN博客_python详细安装教程
2.安装xmind2testcase
pip install xmind2testcase
升级语句:
pip install -U xmind2testcase
3.在命令提示符下输入:xmind2testcase webtool 8000
C:\\Users\\CPIC>xmind2testcase webtool 8000
2021-11-03 12:18:07,650 webtool.application INFO [application - init]: Start initializing the database...
2021-11-03 12:18:07,652 webtool.application INFO [application - init]: Congratulations! the xmind2testcase webtool database has initialized successfully!
* Serving Flask app 'webtool.application' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
2021-11-03 12:18:07,691 werkzeug INFO [_internal - _log]: * Restarting with stat
2021-11-03 12:18:07,691 werkzeug INFO [_internal - _log]: * Restarting with stat
2021-11-03 12:18:08,084 webtool.application INFO [application - init]: Start initializing the database...
2021-11-03 12:18:08,085 webtool.application INFO [application - init]: Congratulations! the xmind2testcase webtool database has initialized successfully!
2021-11-03 12:18:08,092 werkzeug WARNING [_internal - _log]: * Debugger is active!
2021-11-03 12:18:08,092 werkzeug WARNING [_internal - _log]: * Debugger is active!
2021-11-03 12:18:08,107 werkzeug INFO [_internal - _log]: * Debugger PIN: 961-656-232
2021-11-03 12:18:08,107 werkzeug INFO [_internal - _log]: * Debugger PIN: 961-656-232
2021-11-03 12:18:08,194 werkzeug WARNING [_internal - _log]: * Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
2021-11-03 12:18:08,194 werkzeug WARNING [_internal - _log]: * Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
2021-11-03 12:18:08,196 werkzeug INFO [_internal - _log]: * Running on http://10.208.145.81:8000/ (Press CTRL+C to quit)
2021-11-03 12:18:08,196 werkzeug INFO [_internal - _log]: * Running on http://10.208.145.81:8000/ (Press CTRL+C to quit)
3.访问网站
http://127.0.0.1:8000/ 或者
二、xmind格式准备
1.一定要用xmind-8-update9-windows制作用例
2.用例格式编写规则
3.导出结果-csv
4.在cmd下输入命令导出结果
xmind2testcase [path/xmind文件路径] [-csv] [-xml] [-json]
例如:
xmind2testcase D:\\自制测试小工具\\xmind2case用例说明.xmind -csv
三、修改xmind2testcase源代码
1.修改优先级,修改zentao.py
def gen_case_priority(priority):
# 修改前
# mapping = {1: '高', 2: '中', 3: '低'}
# 修改后
mapping = {1: '1', 2: '2', 3: '3', 4: '4'}
if priority in mapping.keys():
return mapping[priority]
else:
# 修改前
return '中'
# 修改后
return '2'
2.修改用例类型,修改zentao.py
def gen_case_type(case_type):
# 修改前
# mapping = {1: '手动', 2: '自动'}
# 修改后
mapping = {1: '功能测试', 2: '其他测试'}
if case_type in mapping.keys():
return mapping[case_type]
else:
# 修改前
# return '手动'
# 修改后
return '功能测试'
3.修改适应阶段,修改zentao.py
def gen_a_testcase_row(testcase_dict):
case_module = gen_case_module(testcase_dict['suite'])
case_title = testcase_dict['name']
case_precontion = testcase_dict['preconditions']
case_step, case_expected_result = gen_case_step_and_expected_result(testcase_dict['steps'])
case_keyword = ''
case_priority = gen_case_priority(testcase_dict['importance'])
case_type = gen_case_type(testcase_dict['execution_type'])
# 修改前
# case_apply_phase = '迭代测试'
# 修改后
case_apply_phase = '系统测试阶段'
row = [case_module, case_title, case_precontion, case_step, case_expected_result, case_keyword, case_priority,
case_type, case_apply_phase]
return row
4.导出文件有空行,修改zentao.py
zentao.py文件找到xmind_to_zentao_csv_file函数,写入文件方法加上newline=''
# 修改前
# with open(zentao_file, 'w', encoding='utf8') as f:
# 修改后
with open(zentao_file, 'w', encoding='utf8', newline='') as f:
5.用例步骤、预期结果序号后多一个空格,修改zentao.py
def gen_case_step_and_expected_result(steps):
case_step = ''
case_expected_result = ''
# 修改后,把+ '. ' + 后的空格去掉 + '.' +
for step_dict in steps:
case_step += str(step_dict['step_number']) + '.' + step_dict['actions'].replace('\\n', '').strip() + '\\n'
case_expected_result += str(step_dict['step_number']) + '.' + \\
step_dict['expectedresults'].replace('\\n', '').strip() + '\\n' \\
6.每导出一个用例步骤和预期结果都会多一个换行符,修改zentao.py
需要去除最后一个换行符
def gen_case_step_and_expected_result(steps):
case_step = ''
case_expected_result = ''
# 修改后,把+ '. ' + 后的空格去掉 + '.' +
for step_dict in steps:
case_step += str(step_dict['step_number']) + '.' + step_dict['actions'].replace('\\n', '').strip() + '\\n'
case_expected_result += str(step_dict['step_number']) + '.' + \\
step_dict['expectedresults'].replace('\\n', '').strip() + '\\n' \\
if step_dict.get('expectedresults', '') else ''
# 添加,去除每个单元格里最后一个换行符
case_step = case_step.rstrip('\\n')
case_expected_result = case_expected_result.rstrip('\\n')
return case_step, case_expected_result
7.填写默认关键词,修改zentao.py
def gen_a_testcase_row(testcase_dict):
case_module = gen_case_module(testcase_dict['suite'])
case_title = testcase_dict['name']
case_precontion = testcase_dict['preconditions']
case_step, case_expected_result = gen_case_step_and_expected_result(testcase_dict['steps'])
# 此处可填写默认关键词
case_keyword = ''
8.去掉用例标题中的空格,修改parser.py
def gen_testcase_title(topics):
"""Link all topic's title as testcase title"""
titles = [topic['title'] for topic in topics]
titles = filter_empty_or_ignore_element(titles)
# when separator is not blank, will add space around separator, e.g. '/' will be changed to ' / '
separator = config['sep']
if separator != ' ':
# 修改前
# separator = ' {} '.format(separator)
# 修改后
separator = ' {} '.format(separator)
return separator.join(titles)
四、实例
说明:以下截图,未执行【7、填写默认关键词,修改zentao.py】、【去掉用例标题中的空格,修改parser.py】步骤
感谢原博客,关于xmind编写规则描述的非常详细!XMind2TestCase使用指南 - hhwu - 博客园
在原博客的基础上,修改了源代码,优化了导出导出结果,欢迎点赞与评论,相互交流学习!
以上是关于超详细xmind2testcase安装与使用规则的主要内容,如果未能解决你的问题,请参考以下文章