目錄
一、安裝python環境
1.配置Python所需環境
2.安裝xmind2testcase
3.在命令提示符下輸入:xmind2testcase webtool 8000
3.訪問網站
二、xmind格式準備
1.一定要用xmind-8-update9-windows制作用例
2.用例格式撰寫規則
3.匯出結果-csv
?4.在cmd下輸入命令匯出結果
三、修改xmind2testcase源代碼
1.修改優先級,修改zentao.py
2.修改用例型別,修改zentao.py
3.修改適應階段,修改zentao.py
4.匯出檔案有空行,修改zentao.py
5.用例步驟、預期結果序號后多一個空格,修改zentao.py
6.每匯出一個用例步驟和預期結果都會多一個換行符,修改zentao.py
7.填寫默認關鍵詞,修改zentao.py
8.去掉用例標題中的空格,修改parser.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 - 博客園
在原博客的基礎上,修改了源代碼,優化了匯出匯出結果,歡迎點贊與評論,相互交流學習!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/347578.html
標籤:其他
上一篇:聯邦學習:保護用戶資料隱私
