Files
WebAutoTest/main.py
CNWei 92d06dd9cf init: 初始化项目
- 创建了基本的项目结构
- 添加了 .gitignore 文件
- 配置了基本的开发环境
- 添加清华镜像源
- 设置了基础的文件夹和文件(如 commons, utils, POM, pytest.ini)

项目说明:
- [项目名称]:Web自动化测试
- [项目描述]:基于pytest,selenium的自动化测试工具
- [开发环境]:Python
2025-04-14 23:05:39 +08:00

23 lines
768 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
import shutil
import datetime
from pathlib import Path
import pytest
from commons.settings import configs
# 指定测试目录
CASES_DIR = configs.CASES_DIR
if __name__ == '__main__':
now = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
# 1启动框架生成临时文件
# -x表示有一个用例失败后面将不执行;-v表示展示用例名称;-c,配置文件所在目录指定pytest.ini路径;--alluredir=temp。指定数据生成目录
pytest.main([str(CASES_DIR), "-x", "-v", "--alluredir=temp"])
# 2生成HTML报告
os.system('allure generate temp -o report --clean') # java程序只能借助操作系统执行
# 3备份日志
# shutil.copy2("logs/pytest.log", f"logs/pytest_{now}.log")