代码拉取完成,页面将自动刷新
# coding=utf-8
import os
import time
import logging
import pytest
import click
from conftest import REPORT_DIR
from config import RunConfig
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
'''
说明:
1、用例创建原则,测试文件名必须以“test”开头,测试函数必须以“test”开头。
2、运行方式:
> python run_tests.py (回归模式,生成HTML报告)
> python run_tests.py -m debug (调试模式)
'''
def init_env(new_report):
"""
初始化测试报告目录
"""
os.mkdir(new_report)
os.mkdir(new_report + "/image")
@click.command()
@click.option('-m', default=None, help='输入运行模式:run 或 debug.')
def run(m):
if m is None or m == "run":
logger.info("回归模式,开始执行✈✈!")
now_time = time.strftime("%Y_%m_%d_%H_%M_%S")
RunConfig.NEW_REPORT = os.path.join(REPORT_DIR, now_time)
init_env(RunConfig.NEW_REPORT)
html_report = os.path.join(RunConfig.NEW_REPORT, "report.html")
xml_report = os.path.join(RunConfig.NEW_REPORT, "junit-xml.xml")
pytest.main(["-s", "-v", RunConfig.cases_path,
"--html=" + html_report,
"--junit-xml=" + xml_report,
"--self-contained-html",
"--maxfail", RunConfig.max_fail,
"--reruns", RunConfig.rerun])
logger.info("运行结束,生成测试报告♥❤!")
elif m == "debug":
print("debug模式,开始执行!")
pytest.main(["-v", "-s", RunConfig.cases_path])
print("运行结束!!")
if __name__ == '__main__':
run()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。