1. 程式人生 > 其它 >7、生成BeautifulReport視覺化報告

7、生成BeautifulReport視覺化報告

1.下載BeautifulReport

git地址:https://github.com/TesterlifeRaymond/BeautifulReport,並將下載的BeautifulReport整個檔案包解壓後,放到本地python的/Lib/site-packages/目錄下

2、建立執行用例的檔案excute_cases

這裡用到unittest.defaultTestLoader.discover()方法批處理整合測試套件,再用BeautifulReport()方法執行用例

excute_cases.py

import
unittest import datetime from BeautifulReport import
BeautifulReport report_path = 'E:/rip_auto/rip_dictionary/rip_datacreate/report/' #報告生成的路徑 now = datetime.datetime.now().strftime('%Y-%m-%d %H_%M_%S') filename = '測試報告' + str(now) #報告生成的名字 if __name__ == '__main__': # "."表示當前目錄,"*tests.py"匹配當前目錄下所有case.py結尾的用例 suite_tests = unittest.defaultTestLoader.discover('
.',pattern="*case.py",top_level_dir=None) # log_path='.'把report放到當前目錄下 BeautifulReport(suite_tests).report(filename=filename, description='URL接入方式', log_path=report_path)

3、注意的點:用例的名字要這樣用,test01_xxx、test02_xxx,要不然執行的順序會亂