# coding: utf-8 # Author:xxx # Date :xxx import unittest import os from commom.logger import Log from BeautifulReport import BeautifulReport import datetime logger = Log() # 测试用例执行的入口 if __name__ == '__main__': logger.warn("main test begin") # start_dir:测试用例所在的文件夹, "./" 表示当前目录 # start_dir = os.path.join(os.getcwd()) start_dir = r"D:\SPMAutoTest\testcase" # 路径 logger.info("start_dir path is : {}".format(start_dir)) # pattern:匹配模式,默认 test*.py pattern = "test_sanJv.py" # 文件 # 加载testcase下面的所用有test_开头的测试用例 cases = unittest.defaultTestLoader.discover(start_dir, pattern) # 路径+文件 result = BeautifulReport(cases) # BR包含了run()方法,执行cases # 指定report.html的文件名 now = datetime.datetime.now().strftime('%Y-%m-%d_%H_%M_%S') filename = now + r"_report.html" dayTime = datetime.datetime.now().strftime('%Y-%m-%d') # 指定report文件存放位置,按照日前格式划分文件夹 report_dir = r"D:/workspace/SPMAutoTest/report/{}/".format(dayTime) # 判断文件夹是否已存在 isExists = os.path.exists(report_dir) if not isExists: os.makedirs(report_dir) # 生成report报告 result.report(filename=filename, description='SmartPMReport', report_dir=report_dir, theme="theme_cyan") logger.warn("自动化生成测试报告, main test end")
生成测试报告
最新推荐文章于 2024-03-11 15:48:25 发布