国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

Python BeautifulReport可視化報告代碼實例

瀏覽:57日期: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 編程
相關文章:
主站蜘蛛池模板: 新乡市| 南漳县| 开原市| 郧西县| 深圳市| 南安市| 久治县| 镇巴县| 长沙县| 渝中区| 嘉峪关市| 若尔盖县| 仪征市| 大港区| 山西省| 洮南市| 临桂县| 仙游县| 左云县| 兴隆县| 通辽市| 大丰市| 乃东县| 吉林市| 洪江市| 兴隆县| 湖州市| 田东县| 恩平市| 泸溪县| 龙江县| 绥化市| 拜泉县| 通渭县| 社会| 麦盖提县| 莱阳市| 伊川县| 定西市| 宝坻区| 且末县|