久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Python BeautifulReport可視化報(bào)告代碼實(shí)例

瀏覽:33日期:2022-07-30 10:05:47

操作步驟

1.下載BeautifulReport文件,本例文件下載地址 最新文件下載地址

2.復(fù)制文件BeautifulReport,至python安裝Libsite-packages位置下

Python BeautifulReport可視化報(bào)告代碼實(shí)例3.

3.導(dǎo)入:from BeautifulReport import BeautifulReport import unittest

4.testXXX測(cè)試用例函數(shù)下可視化報(bào)告用例描述:’’’描述,第一個(gè)測(cè)試用例’’’

5.mian下執(zhí)行:

1.實(shí)例化:ts = unittest.TestSuite()

2.按類加載全部testxxx測(cè)試用例:ts.addTest(unittest.makeSuite(類名))按函數(shù)加載testxxx測(cè)試用例:ts.addTest(類名(‘函數(shù)名’))

3.加載執(zhí)行用例生成報(bào)告:result = BeautifulReport(ts)

4.定義報(bào)告屬性:result.report(description=’XXX報(bào)告XX描述’, filename= ’xxx.html’, log_path=’C:UsersEDZeclipse-workspacepythonTestReport’)

舉例說(shuō)明

#!/usr/bin/python3# encoding:utf-8’’’Created on 2019年9月30日@author: EDZ’’’import unittestfrom BeautifulReport import BeautifulReportimport osimport timeclass HtmlReport(unittest.TestCase): def test_1(self): ’’’描述,第一個(gè)測(cè)試用例’’’ print(’test_1錯(cuò)誤’) self.assertEqual(1, 2) def test_2(self): ’’’描述,第二個(gè)測(cè)試用例’’’ print(’test_2正確’) self.assertEqual(1, 1) def test_3(self): ’’’描述,第三個(gè)測(cè)試用例’’’ print(’test_3錯(cuò)誤’) self.assertEqual(2, 3)if __name__==’__main__’: now = time.strftime('%Y-%m-%d %H%M%S', time.localtime(time.time())) localpath = os.getcwd() print(’本文件目錄位置:’+localpath) filepath = os.path.join(localpath,’Report’) print(’報(bào)告存放路徑 :’+filepath) ts = unittest.TestSuite()#實(shí)例化 #按類加載全部testxxx測(cè)試用例 ts.addTest(unittest.makeSuite(HtmlReport)) #按函數(shù)加載testxxx測(cè)試用例 #ts.addTest(HtmlReport(’test_1’)) filename = now +’.html’ #加載執(zhí)行用例生成報(bào)告 result = BeautifulReport(ts) #定義報(bào)告屬性 result.report(description=’XXX報(bào)告XX描述’, filename= filename, log_path=filepath)

制臺(tái)運(yùn)行結(jié)果

本文件目錄位置:C:UsersEDZeclipse-workspacepythonTest報(bào)告存放路徑 :C:UsersEDZeclipse-workspacepythonTestReportF.F測(cè)試已全部完成,可前往C:UsersEDZeclipse-workspacepythonTestReport查詢測(cè)試報(bào)告

可視化報(bào)告

Python BeautifulReport可視化報(bào)告代碼實(shí)例

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 绥棱县| 吐鲁番市| 白银市| 铜鼓县| 潼关县| 凌海市| 星座| 久治县| 平塘县| 五寨县| 云阳县| 抚远县| 玉树县| 阜南县| 夏河县| 鄂州市| 东安县| 松桃| 蚌埠市| 远安县| 米林县| 错那县| 永宁县| 吴桥县| 胶州市| 北海市| 封开县| 鲁甸县| 周至县| 黄梅县| 丹阳市| 黄浦区| 乌海市| 嘉善县| 贺兰县| 嘉兴市| 台江县| 安福县| 万全县| 石台县| 德格县|