1 Star 0 Fork 0

lubenben/jzjgb_api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
run.py 3.14 KB
一键复制 编辑 原始数据 按行查看 历史
lubenben 提交于 2023-05-19 15:11 +08:00 . 转移
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2022/12/27 17:54
# @Author : 黄姜围
# @Email : jiavin@126.com
import os
import sys
import traceback
import pytest
from utils.other_tools.models import NotificationType
from utils.set_of_control.allure_report_control import AllureFileDispose
from utils.set_of_control.log_control import INFO
from utils.set_of_control.wechat_send_control import WeChatSend
from utils.set_of_control.ding_talk_control import DingTalkSend
from utils.set_of_control.mail_send_control import MailSend
from utils.set_of_control.error_case_control import ErrorCaseExcel
from utils import config
def run():
# 从配置文件中获取项目名称
try:
INFO.logger.info(
"""
_ _ _ _____ _
__ _ _ __ (_) / \\ _ _| |_ __|_ _|__ ___| |_
/ _` | '_ \\| | / _ \\| | | | __/ _ \\| |/ _ \\/ __| __|
| (_| | |_) | |/ ___ \\ |_| | || (_) | | __/\\__ \\ |_
\\__,_| .__/|_/_/ \\_\\__,_|\\__\\___/|_|\\___||___/\\__|
|_|
开始执行{}项目...
""".format(config.project_name)
)
# 判断现有的测试用例,如果未生成测试代码,则自动生成
# TestCaseAutomaticGeneration().get_case_automatic()
pytest.main(['-s', '-W', 'ignore:Module already imported:pytest.PytestWarning',
'--alluredir', './report/tmp', "--clean-alluredir"])
"""
--reruns: 失败重跑次数
--count: 重复执行次数
-v: 显示错误位置以及错误的详细信息
-s: 等价于 pytest --capture=no 可以捕获print函数的输出
-q: 简化输出信息
-m: 运行指定标签的测试用例
-x: 一旦错误,则停止运行
--maxfail: 设置最大失败次数,当超出这个阈值时,则不会在执行测试用例
"--reruns=3", "--reruns-delay=2"
"""
os.system(r"allure generate ./report/tmp -o ./report/html --clean")
allure_data = AllureFileDispose().get_case_count()
notification_mapping = {
NotificationType.DING_TALK.value: DingTalkSend(allure_data).send_ding_notification,
NotificationType.WECHAT.value: WeChatSend(allure_data).send_wechat_notification,
NotificationType.EMAIL.value: MailSend(allure_data).send_main
}
if config.notification_type != NotificationType.DEFAULT.value:
notification_mapping.get(config.notification_type)()
if config.excel_report:
ErrorCaseExcel().write_case()
# 程序运行之后,自动启动报告,如果不想启动报告,可注释这段代码
os.system(f"allure serve ./report/tmp -h 127.0.0.1 -p 9999")
except Exception:
# 如有异常,相关异常发送邮件
e = traceback.format_exc()
send_email = MailSend(AllureFileDispose.get_case_count())
send_email.error_mail(e)
raise
if __name__ == '__main__':
run()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lubenben/jzjgb_api.git
git@gitee.com:lubenben/jzjgb_api.git
lubenben
jzjgb_api
jzjgb_api
master

搜索帮助