xmind2case-xmind to use case format and usage records

xmind2case-xmind to use case format and usage records

First, the purpose

In order to allow the use cases written by xmind to import the existing Zen Tao, a small change was made according to the company Zen Tao configuration

Source adjustment

# 1、修改了优先级与现有禅道对应
# 2、修改禅道中对应获取用例的类型,“手动”更改为“功能测试”(现有禅道的预置类型很多,暂时不过多添加)并增加默认为“功能测试”
# 3、同步获取禅道的csv模板格式
# 4、修改多条用例在同一个列表中,增加自动换行

def gen_case_priority(priority):
    # 创建优先级
    mapping = {
    
    1: '1', 2: '2', 3: '3'}
    if priority in mapping.keys():
        return mapping[priority]
    else:
        return '2'

def gen_case_type(case_type):
    # 创建用例类型
    mapping = {
    
    1: '功能测试', 2: '接口测试'}
    if case_type in mapping.keys():
        return mapping[case_type]
    else:
        return '功能测试'
        
def xmind_to_zentao_csv_file(xmind_file):
    """将 XMind 文件转换为 禅道 csv 文件"""
    xmind_file = get_absolute_path(xmind_file)
    logging.info('开始将XMind文件(%s)转换成zentao文件...', xmind_file)
    testcases = get_xmind_testcase_list(xmind_file)

    fileheader = ["所属模块", "用例标题", "前置条件", "步骤", "预期", "关键词", "优先级", "用例类型", "适用阶段"]
    zentao_testcase_rows = [fileheader]
    for testcase in testcases:
        row = gen_a_testcase_row(testcase)
        zentao_testcase_rows.append(row)
        
        
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 ''

    return case_step, case_expected_result    
        

2. Specifications for writing xmind use cases

There are many kinds of writing rules, mainly two commonly used ones

1. Writing a single use case

insert image description here

As shown in the picture, the title of the file can be ignored, just write one and remember it by yourself. This code is filtered, mainly talking about the next 4 parts:
1. Functional modules (low): This is mainly to distinguish by yourself, because there is no Zen Tao The openapi can't get the preset management module, so just write it yourself, it's not very important.

2. Use case name (high): This is mainly used to record the use cases after ZenTao is imported. It is best to write in detail, for example: User Center - New Filter Field - Channel ID-6685 (the channel ID is followed by requirements No., so that you can see it conveniently).

3. Steps (high): Write your own test steps, for example: enter an integer for the channel id, just write it so that you can understand it.

4. Expected result (middle): Get the expected result of the use case according to the requirements and steps, for example: input success or input failure.

The Zen Tao use case structure after the above writing style conversion is as follows ↓:

insert image description here

The downloaded ZenTao use case style diagram is as follows ↓:

insert image description here

2. Writing multiple use cases

insert image description here

As shown in the figure, the template style still takes the above four parts as the main core, module-use case title-step-expected result

The Zen Tao use case structure after the above writing style conversion is as follows ↓:

image

The downloaded ZenTao use case style diagram is as follows ↓:

insert image description here

3. Introducing the Way of Zen

1. Log in to ZenTao and select the use case library – click Import CSV
2. Upload and import the converted csv use case. The uploaded style is as follows:
insert image description here

Special reminder: The priority in the title of the use case needs to be written, which is red "1", which is convenient for distinguishing the columns of the title when converting

Guess you like

Origin blog.csdn.net/qq_34004131/article/details/120878958