Beautiful Report 異步併發測試html報告

version_ :python3.7html

下載BeautifulReport   https://github.com/TesterlifeRaymond/BeautifulReport/archive/master.zippython

,修改解壓文件名稱爲BeautifulReport 丟進python 的site-packagesgit

pip3 install tomorrowgithub

安裝異步tomorrow庫,進入C:\Python37\Lib\site-packages\tomorrow\tomorrow.py修改異步函數名稱以及調用函數名稱爲以下:異步

 

 

import unittest
from BeautifulReport import BeautifulReport
import os
from tomorrow import threads

curpath = os.path.dirname(os.path.realpath(__file__))
casepath = os.path.join(curpath, "case")
if not os.path.exists(casepath):
print("測試用例需放到‘case’文件目錄下")
os.mkdir(casepath)
reportpath = os.path.join(curpath, "report")
if not os.path.exists(reportpath): os.mkdir(reportpath)


def add_case(case_path=casepath, rule="test*.py"):
'''加載全部的測試用例'''
discover = unittest.defaultTestLoader.discover(case_path,
pattern=rule,
top_level_dir=None)
return discover

@threads(3)
def run(test_suit):
result = BeautifulReport(test_suit)
result.report(filename='report.html', description='測試deafult報告', log_path='report')

if __name__ == "__main__":
# 用例集合
cases = add_case()

print(cases)
for i in cases:
run(i)

 放置test_case.py 到case後函數

 

 運行上述代碼所在文件程序入口測試

檢查html報告效果:ui

相關文章
相關標籤/搜索