最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

如何利用python將Xmind用例轉(zhuǎn)為Excel用例

 更新時間:2022年06月07日 16:20:59   作者:sinat_18866031  
這篇文章主要介紹了如何利用python將Xmind用例轉(zhuǎn)為Excel用例,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下

1、Xmind用例編寫規(guī)范

  • 1:需求大模塊
  • 2:大模塊中的小模塊(需要根據(jù)需求來看需要多少層)
  • 3:用例等級和用例名稱
    • 用例等級(轉(zhuǎn)換成Excel文件后,1為High, 2 為 Middle, 3為Low)
    • 轉(zhuǎn)換成excel時,用例的名稱為(框出來的1-2-3組合而成),意味著在標(biāo)等級及之前的節(jié)點(diǎn)會組合成用例名稱
  • 4:步驟
  • 5:期望結(jié)果
  • 6:預(yù)置條件,轉(zhuǎn)換成excel時相同層級下的用例會為同一個預(yù)置條件

2、轉(zhuǎn)換代碼

需要安裝python3環(huán)境
需要安裝 xlwt、xmindparser 這兩個第三方包

XmindExcel.py 文件代碼

# coding=utf-8
import time
import xlwt
from past.builtins import raw_input
from xmindparser import xmind_to_dict
def resolvePath(dict, lists, title):
? ? # title去除首尾空格
? ? title = title.strip()
? ? # 如果title是空字符串,則直接獲取value
? ? if len(title) == 0:
? ? ? ? concatTitle = dict['title'].strip()
? ? elif "makers" in dict.keys():
? ? ? ? if "priority-" in str(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()

? ? if dict.__contains__('topics') == False:
? ? ? ? lists.append(concatTitle)
? ? else:
? ? ? ? for d in dict['topics']:
? ? ? ? ? ? resolvePath(d, lists, concatTitle
def xmind_cat(list, excelname, groupname):
? ? f = xlwt.Workbook()
? ? sheet = f.add_sheet(groupname, cell_overwrite_ok=True)
? ? row0 = ["測試用例編號", "用例標(biāo)題", "預(yù)置條件", "執(zhí)行方式", "優(yōu)先級", "測試步驟", "預(yù)期結(jié)果", "所屬項(xiàng)目"]
? ? # 生成第一行中固定表頭內(nèi)容
? ? for i in range(0, len(row0)):
? ? ? ? sheet.write(0, i, row0[i])

? ? # 增量索引
? ? index = 0
? ? # case級別
? ? case_leve_index = ""
? ? # 前置條件
? ? case_pre_condition = []
? ? pre_num = 0

? ? for h in range(0, len(list)):
? ? ? ? # print("list:",list)
? ? ? ? lists = []
? ? ? ? resolvePath(list[h], lists, '')
? ? ? ? for j in range(0, len(lists)):
? ? ? ? ? ? # 將xmind轉(zhuǎn)成excel
? ? ? ? ? ? lists[j] = lists[j].split('\t')
? ? ? ? ? ? try:
? ? ? ? ? ? ? ? # print(index)
? ? ? ? ? ? ? ? if "【預(yù)置條件】" in lists[j][-1] or "【前置條件】" in lists[j][-1]:
? ? ? ? ? ? ? ? ? ? case_pre_condition.append(lists[j])
? ? ? ? ? ? ? ? ? ? pre_num += 1
? ? ? ? ? ? ? ? else:
? ? ? ? ? ? ? ? ? ? case_leve = ""
? ? ? ? ? ? ? ? ? ? for n in range(len(lists[j])):
? ? ? ? ? ? ? ? ? ? ? ? if 'priority-' in str(lists[j][n]):
? ? ? ? ? ? ? ? ? ? ? ? ? ? case_leve_index = n-1
? ? ? ? ? ? ? ? ? ? ? ? ? ? if "priority-1" in str(lists[j][n]):
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case_leve = "High"
? ? ? ? ? ? ? ? ? ? ? ? ? ? elif "priority-2" in str(lists[j][n]):
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case_leve = "Middle"
? ? ? ? ? ? ? ? ? ? ? ? ? ? elif "priority-3" in str(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) ?# 標(biāo)題
? ? ? ? ? ? ? ? ? ? if len(lists[j][case_leve_index:-1]) < 2:
? ? ? ? ? ? ? ? ? ? ? ? sheet.write(j + index + 1 - pre_num, 6, lists[j][case_leve_index + 1]) ? # 期望結(jié)果
? ? ? ? ? ? ? ? ? ? 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]) ?# 期望結(jié)果
? ? ? ? ? ? ? ? ? ? sheet.write(j + index + 1- pre_num, 3, "手動") ?# 執(zhí)行方式
? ? ? ? ? ? ? ? ? ? sheet.write(j + index + 1 - pre_num, 4, case_leve)

? ? ? ? ? ? ? ? ? ? # 預(yù)置條件
? ? ? ? ? ? ? ? ? ? if len(case_pre_condition) > 0:
? ? ? ? ? ? ? ? ? ? ? ? for pre_list in case_pre_condition:
? ? ? ? ? ? ? ? ? ? ? ? ? ? if set(pre_list[:-1]) < set(lists[j]):
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sheet.write(j + index + 1 - pre_num, 2, pre_list[-1])
? ? ? ? ? ? except:
? ? ? ? ? ? ? ? print("請檢查編寫的用例是否符合規(guī)范:", lists[j])

? ? ? ? ? ? # 遍歷結(jié)束lists,給增量索引賦值,跳出for j循環(huán),開始for h循環(huán)
? ? ? ? ? ? if j == len(lists) - 1:
? ? ? ? ? ? ? ? index += len(lists)

? ? ? ? f.save(excelname)
def maintest(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' % excelname)
? ? except:
? ? ? ? print('請確認(rèn)后重試:\n1.用例文件路徑中不能有空格換行符\n2.請使用python3運(yùn)行\(zhòng)n3.檢查xmind文件中不能有亂碼或無法識別的字符(xmind自帶表情字符除外)\n4.檢查是否將已生成的excel文件未關(guān)閉')

3、使用

運(yùn)行XmindExcel.py文件,輸入文件目錄運(yùn)行即可。生成的Excel文件會在Xmind文件的同路徑下,文件名稱與Xmind文件名稱一致

到此這篇關(guān)于如何利用python將Xmind用例轉(zhuǎn)為Excel用例的文章就介紹到這了,更多相關(guān)python Excel用例內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 詳解pytorch tensor和ndarray轉(zhuǎn)換相關(guān)總結(jié)

    詳解pytorch tensor和ndarray轉(zhuǎn)換相關(guān)總結(jié)

    這篇文章主要介紹了詳解pytorch tensor和ndarray轉(zhuǎn)換相關(guān)總結(jié),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • python3?queue多線程通信

    python3?queue多線程通信

    這篇文章主要介紹了python3?queue多線程通信,??Queue???對象已經(jīng)包含了必要的鎖,所以你可以通過它在多個線程間多安全地共享數(shù)據(jù),更多相關(guān)內(nèi)容需要的朋友可以參考一下下文文章內(nèi)容
    2022-07-07
  • Python中文本和數(shù)字相等判斷方式

    Python中文本和數(shù)字相等判斷方式

    這篇文章主要介紹了Python中文本和數(shù)字相等判斷方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • Python常見數(shù)據(jù)類型轉(zhuǎn)換操作示例

    Python常見數(shù)據(jù)類型轉(zhuǎn)換操作示例

    這篇文章主要介紹了Python常見數(shù)據(jù)類型轉(zhuǎn)換操作,結(jié)合實(shí)例形式分析了Python針對列表、集合、元組、字典等數(shù)據(jù)類型轉(zhuǎn)換的相關(guān)操作技巧,需要的朋友可以參考下
    2019-05-05
  • python scrapy框架中Request對象和Response對象的介紹

    python scrapy框架中Request對象和Response對象的介紹

    本文介紹了python基礎(chǔ)之scrapy框架中Request對象和Response對象的介紹,Request對象主要是用來請求數(shù)據(jù),爬取一頁的數(shù)據(jù)重新發(fā)送一個請求的時候調(diào)用,Response對象一般是由scrapy給你自動構(gòu)建的,因此開發(fā)者不需要關(guān)心如何創(chuàng)建Response對象,下面來一起來了解更多內(nèi)容吧
    2022-02-02
  • python中argparse模塊及action='store_true'詳解

    python中argparse模塊及action='store_true'詳解

    argparse?是一個用來解析命令行參數(shù)的?Python?庫,它是?Python?標(biāo)準(zhǔn)庫的一部分,這篇文章主要介紹了python中argparse模塊及action=‘store_true‘詳解,需要的朋友可以參考下
    2023-02-02
  • python區(qū)塊鏈實(shí)現(xiàn)簡版工作量證明

    python區(qū)塊鏈實(shí)現(xiàn)簡版工作量證明

    這篇文章主要為大家介紹了python區(qū)塊鏈實(shí)現(xiàn)簡版工作量證明詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05
  • 舉例詳解Python中的split()函數(shù)的使用方法

    舉例詳解Python中的split()函數(shù)的使用方法

    這篇文章主要介紹了舉例詳解Python中的split()函數(shù)的使用方法,split()函數(shù)的使用是Python學(xué)習(xí)當(dāng)中的基礎(chǔ)知識,通常用于將字符串切片并轉(zhuǎn)換為列表,需要的朋友可以參考下
    2015-04-04
  • Python實(shí)現(xiàn)簡單的猜單詞小游戲

    Python實(shí)現(xiàn)簡單的猜單詞小游戲

    這篇文章主要為大家詳細(xì)介紹了Python實(shí)現(xiàn)簡單的猜單詞小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-10-10
  • python操作CouchDB的方法

    python操作CouchDB的方法

    這篇文章主要介紹了python操作CouchDB的方法,包括了couchDb庫安裝、連接服務(wù)器、創(chuàng)建數(shù)據(jù)庫、查詢數(shù)據(jù)庫、遍歷數(shù)據(jù)庫等常用的操作,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2014-10-10

最新評論

兰溪市| 溧阳市| 青川县| 昭觉县| 福建省| 岳阳市| 怀远县| 阜新| 南皮县| 屯门区| 永春县| 东辽县| 理塘县| 平原县| 丹东市| 元谋县| 阜新市| 诸暨市| 扶余县| 宁阳县| 泊头市| 谷城县| 乐山市| 富平县| 遵化市| 梨树县| 噶尔县| 铜川市| 嘉黎县| 崇州市| 延津县| 双峰县| 永新县| 友谊县| 肃北| 哈密市| 蓝山县| 鹤峰县| 久治县| 华容县| 衡阳市|