代码拉取完成,页面将自动刷新
#!/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()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。