下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
第如何利用python將Xmind用例轉為Excel用例目錄1、Xmind用例編寫規(guī)范2、轉換代碼3、使用
1、Xmind用例編寫規(guī)范
1:需求大模塊2:大模塊中的小模塊(需要根據(jù)需求來看需要多少層)3:用例等級和用例名稱用例等級(轉換成Excel文件后,1為High,2為Middle,3為Low)轉換成excel時,用例的名稱為(框出來的1-2-3組合而成),意味著在標等級及之前的節(jié)點會組合成用例名稱4:步驟5:期望結果6:預置條件,轉換成excel時相同層級下的用例會為同一個預置條件
2、轉換代碼
需要安裝python3環(huán)境
需要安裝xlwt、xmindparser這兩個第三方包
XmindExcel.py文件代碼
#coding=utf-8
importtime
importxlwt
frompast.builtinsimportraw_input
fromxmindparserimportxmind_to_dict
defresolvePath(dict,lists,title):
#title去除首尾空格
title=title.strip()
#如果title是空字符串,則直接獲取value
iflen(title)==0:
concatTitle=dict['title'].strip()
elif"makers"indict.keys():
if"priority-"instr(dict["makers"]):
concatTitle=title+'\t'+dict['title'].strip()+"\t"+str(dict["makers"])
else:
concatTitle=title+'\t'+dict['title'].strip()
else:
concatTitle=title+'\t'+dict['title'].strip()
ifdict.__contains__('topics')==False:
lists.append(concatTitle)
else:
fordindict['topics']:
resolvePath(d,lists,concatTitle
defxmind_cat(list,excelname,groupname):
f=xlwt.Workbook()
sheet=f.add_sheet(groupname,cell_overwrite_ok=True)
row0=["測試用例編號","用例標題","預置條件","執(zhí)行方式","優(yōu)先級","測試步驟","預期結果","所屬項目"]
#生成第一行中固定表頭內(nèi)容
foriinrange(0,len(row0)):
sheet.write(0,i,row0[i])
#增量索引
index=0
#case級別
case_leve_index=""
#前置條件
case_pre_condition=[]
pre_num=0
forhinrange(0,len(list)):
#print("list:",list)
lists=[]
resolvePath(list[h],lists,'')
forjinrange(0,len(lists)):
#將xmind轉成excel
lists[j]=lists[j].split('\t')
try:
#print(index)
if"【預置條件】"inlists[j][-1]or"【前置條件】"inlists[j][-1]:
case_pre_condition.append(lists[j])
pre_num+=1
else:
case_leve=""
forninrange(len(lists[j])):
if'priority-'instr(lists[j][n]):
case_leve_index=n-1
if"priority-1"instr(lists[j][n]):
case_leve="High"
elif"priority-2"instr(lists[j][n]):
case_leve="Middle"
elif"priority-3"instr(lists[j][n]):
case_leve="Low"
lists[j].pop(n)
break
case_name="-".join(lists[j][:case_leve_index+1])
sheet.write(j+index+1-pre_num,1,case_name)
#標題
iflen(lists[j][case_leve_index:-1])2:
sheet.write(j+index+1-pre_num,6,lists[j][case_leve_index+1])
#期望結果
else:
sheet.write(j+index+1-pre_num,5,lists[j][case_leve_index+1])
#步驟
sheet.write(j+index+1-pre_num,6,lists[j][case_leve_index+2])
#期望結果
sheet.write(j+index+1-pre_num,3,"手動")
#執(zhí)行方式
sheet.write(j+index+1-pre_num,4,case_leve)
#預置條件
iflen(case_pre_condition)0:
forpre_listincase_pre_condition:
ifset(pre_list[:-1])set(lists[j]):
sheet.write(j+index+1-pre_num,2,pre_list[-1])
except:
print("請檢查編寫的用例是否符合規(guī)范:",lists[j])
#遍歷結束lists,給增量索引賦值,跳出forj循環(huán),開始forh循環(huán)
ifj==len(lists)-1:
index+=len(lists)
f.save(excelname)
defmaintest(filename,excelname):
out=xmind_to_dict(filename)
groupname=out[0]['topic']['title']
xmind_cat(out[0]['topic']['topics'],excelname,groupname)
if__name__=='__main__':
try:
path=raw_input("請輸入Xmind用例文件路徑,可將文件拖拽到此處:")
filename=path
excelname=path.rstrip('xmind')+'xls'
maintest(filename,excelname)
print('SUCCESS!\n生成用例成功,用例目錄:%s'%exceln
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 新材料應用推廣保證承諾書4篇范文
- 公司合作期間誠實守信經(jīng)營保證承諾書(4篇)
- 試驗室人員扣分制度規(guī)范
- 規(guī)范公務員借調(diào)抽調(diào)制度
- 語言文字規(guī)范化各種制度
- 計劃部作業(yè)流程規(guī)范制度
- ?;饭芾碇贫燃耙?guī)范
- 醫(yī)療經(jīng)營制度管理規(guī)范
- 完善鑒定技術規(guī)范制度
- 衛(wèi)生監(jiān)督協(xié)管制度規(guī)范
- 2023年廣東交通職業(yè)技術學院招聘考試真題
- 廣東省大灣區(qū)2023-2024學年高一上學期期末生物試題【含答案解析】
- 《合理利用網(wǎng)絡》(優(yōu)質(zhì)課件)
- 中深度鎮(zhèn)靜紅外線全身熱療方法課件
- 第四單元地理信息技術的應用課件 【高效課堂+精研精講】高中地理魯教版(2019)必修第一冊
- 魯科版高中化學必修一教案全冊
- 提高隧道初支平整度合格率
- 2023年版測量結果的計量溯源性要求
- 建筑能耗與碳排放研究報告
- GB 29415-2013耐火電纜槽盒
- 中國古代經(jīng)濟試題
評論
0/150
提交評論