36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
||
import os
|
||
import time
|
||
|
||
import pytest
|
||
from shutil import copyfile
|
||
|
||
from common.config import PathConfig
|
||
from tools.date_tool.get_date import GetDate
|
||
|
||
|
||
now_time = GetDate().get_now_time("%Y-%m-%d_%H-%M_%S")
|
||
|
||
root_path = PathConfig.root_path # 项目根路径
|
||
cases_path = PathConfig.case_path # 测试用例路径
|
||
common_path = PathConfig.common_path # 公共文件路径
|
||
report_path = os.path.join(PathConfig.report_path, now_time+os.sep) # 测试报告路径
|
||
html_path = os.path.join(report_path, 'html') # 测试报告html文件夹路径
|
||
|
||
now_time = time.strftime("%Y-%m-%d %H.%M.%S", time.localtime())
|
||
|
||
|
||
def run():
|
||
pytest.main(["-v", "-s",
|
||
r"--alluredir=" + report_path,
|
||
"--clean-alluredir"])
|
||
|
||
# 复制测试环境信息到测试报告目录下
|
||
# os.mkdir(report_path)
|
||
copyfile(common_path + "environment.properties", report_path + "environment.properties")
|
||
os.system('allure generate ' + report_path + ' --clean -o ' + html_path) # -o 参数是将报告内容保存到指定的文件夹下 -c接目录,清理上次的报告数据
|
||
|
||
|
||
if __name__ == '__main__':
|
||
run()
|