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,要不然执行的顺序会乱

 

 

posted @ 2021-08-25 14:02  东北小酱  阅读(168)  评论(0)    收藏  举报