Xmind用例导入到TAPD的解决方案(xmind应用技巧)万万没想到

随心笔谈12个月前发布 admin
92 0

#修改表头
def xmind_to_zentao_csv_file(xmind_file):
“””Convert XMind file to a zentao csv file”””
xmind_file=get_absolute_path(xmind_file) #路径处理
logging.info(‘Start converting XMind file(%s) to zentao file…’, xmind_file)
testcases=get_xmind_testcase_list(xmind_file) #解析xmind文档,得到原始数据
# print(“testcases”,testcases)
#fileheader=[“所属模块”,”用例标题”,”前置条件”,”步骤”, “预期”, “关键词>用例状态”, “优先级”, “用例类型”, “适用阶段?”]
fileheader_tapd=[“用例目录”,”用例名称”,”需求ID”,”前置条件”,”用例步骤”,”预期结果”,”用例类型”,”用例状态”,”用例等级”,”创建人”,”测试结果”,”备注说明”]

zentao_testcase_rows=[fileheader_tapd]
for testcase in testcases:
#row=gen_a_testcase_row(testcase)
row=gen_a_testcase_row_tapd(testcase)
zentao_testcase_rows.append(row)
zentao_file=xmind_file[:-6] + ‘.csv’
if os.path.exists(zentao_file): #判断括号里的文件是否存在
os.remove(zentao_file)
# logging.info(‘The zentao csv file already exists, return it directly: %s’, zentao_file)
# return zentao_file

with open(zentao_file, ‘w’, encoding=’utf8′) as f:
writer=csv.writer(f)
writer.writerows(zentao_testcase_rows)
logging.info(‘Convert XMind file(%s) to a zentao csv file(%s) successfully!’, xmind_file, zentao_file)

return zentao_file

#修改为tapd的数据格式、增加获取需求ID
def gen_a_testcase_row_tapd(testcase_dict):

#用例标题
case_title=testcase_dict[‘name’]
#需求ID 产品名称里的目录获取
requirement_id, product_catalog=gen_requirement_id(testcase_dict[‘product’])
# 所属模块
case_module=product_catalog +”-” + gen_case_module(testcase_dict[‘suite’])

#前置条件
case_precontion=testcase_dict[‘preconditions’]
#步骤 预期结果
case_step, case_expected_result=gen_case_step_and_expected_result(testcase_dict[‘steps’])
#用例类型
case_type=gen_case_type(testcase_dict[‘execution_type’])
# case_type=”功能测试”
#用例状态
case_status=”正常”
#用例等级
case_priority=gen_case_priority(testcase_dict[‘importance’])
#创建人
case_created_by=””
#测试结果
case_actual_result=””

row=[case_module,case_title,requirement_id,case_precontion,case_step,case_expected_result,case_type,case_status,case_priority,case_created_by,case_actual_result]
return row

#修改用例类型
def get_execution_type(topics):
labels=[topic.get(‘label’, ”) for topic in topics]
labels=filter_empty_or_ignore_element(labels)
exe_type=1
for item in labels[::-1]:
if item.lower() in [‘性能测试’, ‘性能’]:
exe_type=2
break
if item.lower() in [‘功能测试’, ‘功能’]:
exe_type=1
break
if item.lower() in [‘安全测试’, ‘安全’,’安全性测试’]:
exe_type=3
break
if item.lower() in [‘其他’]:
exe_type=4
break
return exe_type

© 版权声明

相关文章