增加失败重跑次数、重跑间隔时间及最大失败数设置

This commit is contained in:
wangjie 2024-03-20 18:52:50 +08:00
parent f4276e1b25
commit cd1ce75c92
4 changed files with 16 additions and 13 deletions

View File

@ -61,16 +61,16 @@
├── configs 项目配置信息目录
│ ├── dir_path_config.py 项目各目录路径文件
│ ├── lins_environment.ini 项目全局环境变量配置文件(弃用)
│ ├── lins_environment.py 项目全局环境变量
│ └── mail_config.yaml 发送邮件配置信息
│ └── lins_environment.py 项目全局环境变量
├── conftest.py pytest共享文件设置allure报告及其他报告的环境变量
├── datas 测试数据存放目录
│ ├── login.yaml 登录测试的数据demo
├── outFiles 各种输出文件存放目录
│ ├── logs 日志存放目录
│ ├── pytest_report pytest报告存放目录
│ ├── report allure报告存放目录
│ └── screenShot 截图存放目录
│ ├── pytest_result pytest-json报告数据存放目录
│ ├── allure_report allure报告存放目录
│ └── Temp allure报告原始数据存放目录
├── pageApi 各业务接口对象类
│ ├── alarms.py 预警相关接口demo
│ └── login.py 登录相关接口demo
@ -80,7 +80,7 @@
├── testCase 测试用例存放目录
│ ├── conftest.py pytest共享文件提供各种方法及前后置操作
│ ├── test_alarms.py 预警测试用例demo
│ └── test_login.py 预警测试用例demo
│ └── test_login.py 登录测试用例demo
└── utils 测试工具存放目录
├── config_handle.py 读取config配置文件的方法
├── allure_handle.py allure相关工具

View File

@ -18,6 +18,15 @@ from utils.jenkins_handle import ProjectName, BUILD_NUMBER, ALLURE_URL, BUILD_UR
# 设置运行环境
ENV = Environment.TEST
# 失败重跑次数
rerun = 5
# 失败重跑间隔时间
reruns_delay = 5
# 当用例达到最大失败数,整个测试停止执行
max_fail = 100
# 设置是否需要发送邮件Ture发送False不发送
IS_SEND_EMAIL = False

View File

@ -1,7 +0,0 @@
mail_subject: 'lins接口自动化测试报告'
sender_mail_address: 'xxxx@xxxx.com'
sender_username: 'xxxx@xxxx.com'
sender_password: PeeuobDpukzEcD54
receiver_mail_list: [ 'xxxx@xxxx.com', ]
smtp_domain: 'smtp.exmail.qq.com'
smtp_port: 465

3
run.py
View File

@ -20,7 +20,7 @@ from utils.command_parser import command_parser
from common.mail_sender import MailSender
from common.robot_sender import EnterpriseWechatNotification
from common.settings import IS_SEND_EMAIL, IS_SEND_WECHAT, wechat_webhook_url, wechat_content, email_content, \
email_config
email_config, max_fail, rerun, reruns_delay
from configs.dir_path_config import BASE_DIR, TEMP_DIR, PYTEST_REPORT_DIR, PYTEST_RESULT_DIR, ALLURE_REPORT_DIR
from utils.data_handle import DataProcessor
from utils.file_handle import FileHandle
@ -46,6 +46,7 @@ if __name__ == '__main__':
# '-q', # 代表 "quiet",即安静模式,它可以将 pytest 的输出精简化,只输出测试用例的执行结果,而不会输出额外的信息,如测试用例的名称、执行时间等等
'-vs', # 指定输出用例执行信息并打印程序中的print/logging输出
'testCase/', # 执行用例的目录
f"--maxfail={max_fail}", f"--reruns={rerun}", f"--reruns-delay={reruns_delay}", # 指定最大失败次数、重运行次数和重运行间隔时间
'--alluredir', f'{TEMP_DIR}', '--clean-alluredir', # 先清空旧的alluredir目录再将生成Allure原始报告需要的数据,并存放在 /Temp 目录
f'--html={os.path.join(PYTEST_REPORT_DIR, "pytest_report.html")}', # 指定pytest-html报告的存放位置
'--self-contained-html', # 将css样式合并到pytest-html报告文件中便于发送邮件