xmind2testcase导出禅道用例中参数修正

感谢老师博文https://blog.csdn.net/eastfox8609/article/details/90210968?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-4

1.安装xmind2testcase

pip install xmind2testcase

如果需要升级:pip3 install -U xmind2testcase 

2.运行

xmind2testcase webtool

访问地址为:127.0.0.1:5001

 3.输入地址:127.0.0.1:5001

选中xmind文件,导出CSV

——————————————————————————————————————————————————————————————————

好了,现在开始修改xmind2testcase的源码了

xmind2testcase包的路径地址:在python根目录的Libsite-packagesxmind2testcase

修改前:

 修改后:

xmind上的用例如图所示

 

找到parser.py

在config={}中添加

 #用例类型的配置
 'type_sep': '
----
',

在 def parse_a_testcase(case_dict, parent): 

#修改
#testcase.summary = summary if summary else testcase.name
#改为
#设置批注默认值为''
testcase.summary = summary if summary else ""



#添加
#用例类型赋值,默认为'无'
execution_type = gen_testcase_type(topics)
testcase.execution_type = execution_type if execution_type else '无'

在该文件底部添加方法

#从xmind的内容中获取用例类型的值
def gen_testcase_type(topics):
    labels = [topic['label'] for topic in topics]
    labels = filter_empty_or_ignore_element(labels)
    return config['type_sep'].join(labels)

2.打开zentao.py

找到def gen_a_testcase_row(testcase_dict):

#修改
case_type = gen_case_type(testcase_dict['execution_type'])
#改为
#适用用例类型的csv输出
case_type = gen_case_type(testcase_dict['summary'])


#修改
#case_apply_phase = '迭代测试'
#改为
#适用阶段的csv输出
case_apply_phase = gen_case_apply_phase(testcase_dict['summary'])

找到 def gen_case_priority(priority):     禅道不能识别高中低,要想对应地改为数字123

def gen_case_priority(priority):
    #mapping = {1: "", 2: "", 3: ""}
    mapping = {1: 1, 2: 2, 3: 3}
    if priority in mapping.keys():
        return mapping[priority]
    else:
        #return ''
         return 2
#修改方法
#def gen_case_type(case_type):
#    mapping = {1: '手动', 2: '自动'}
#    if case_type in mapping.keys():
#        return mapping[case_type]
#    else:
#        return '手动'
#改为 #用例类型默认值转换 def gen_case_type(case_type): if case_type=='': return '功能测试' else: return case_type
#添加方法 #适用阶段默认值转换 def gen_case_apply_phase(case_apply_phase):
if case_apply_phase=='': return '功能测试阶段' else: return case_apply_phase

好啦,还想改其他的也可以尝试改一下,大功告成

原文地址:https://www.cnblogs.com/hjy123/p/13366752.html