1 Star 0 Fork 0

setionlee/pyautoTest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
run_tests.py 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
defnngj 提交于 2020-07-19 23:04 +08:00 . update test report
# 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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/setionlee/pyautoTest.git
git@gitee.com:setionlee/pyautoTest.git
setionlee
pyautoTest
pyautoTest
master

搜索帮助