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

您的位置:首頁技術文章
文章詳情頁

Python BeautifulReport可視化報告代碼實例

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

操作步驟

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

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

Python BeautifulReport可視化報告代碼實例3.

3.導入:from BeautifulReport import BeautifulReport import unittest

4.testXXX測試用例函數下可視化報告用例描述:’’’描述,第一個測試用例’’’

5.mian下執行:

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

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

3.加載執行用例生成報告:result = BeautifulReport(ts)

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

舉例說明

#!/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): ’’’描述,第一個測試用例’’’ print(’test_1錯誤’) self.assertEqual(1, 2) def test_2(self): ’’’描述,第二個測試用例’’’ print(’test_2正確’) self.assertEqual(1, 1) def test_3(self): ’’’描述,第三個測試用例’’’ print(’test_3錯誤’) 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(’報告存放路徑 :’+filepath) ts = unittest.TestSuite()#實例化 #按類加載全部testxxx測試用例 ts.addTest(unittest.makeSuite(HtmlReport)) #按函數加載testxxx測試用例 #ts.addTest(HtmlReport(’test_1’)) filename = now +’.html’ #加載執行用例生成報告 result = BeautifulReport(ts) #定義報告屬性 result.report(description=’XXX報告XX描述’, filename= filename, log_path=filepath)

制臺運行結果

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

可視化報告

Python BeautifulReport可視化報告代碼實例

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 岳阳市| 哈巴河县| 芜湖市| 崇明县| 申扎县| 庆元县| 巨鹿县| 调兵山市| 壶关县| 务川| 即墨市| 安远县| 甘孜| 武宁县| 门头沟区| 台前县| 桐梓县| 建宁县| 渭源县| 调兵山市| 长寿区| 寻甸| 阳原县| 塔城市| 临漳县| 淮北市| 克拉玛依市| 钟山县| 平武县| 六盘水市| 黄龙县| 合水县| 潼关县| 衡山县| 河南省| 万载县| 定安县| 昌图县| 汽车| 广丰县| 邢台县|