- 创建了基本的项目结构 - 添加了 .gitignore 文件 - 配置了基本的开发环境 - 添加清华镜像源 - 设置了基础的文件夹和文件(如 commons, utils, POM, pytest.ini) 项目说明: - [项目名称]:Web自动化测试 - [项目描述]:基于pytest,selenium的自动化测试工具 - [开发环境]:Python
23 lines
768 B
Python
23 lines
768 B
Python
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")
|