1 Star 1 Fork 2

dingyiaaa/ApiTestFramework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
DD 提交于 2025-04-16 13:44 +08:00 . Initial commit
import os
import shutil
import subprocess
def run_pytest_with_allure():
# 报告路径
result_dir = "reports"
report_dir = "allure-report"
# 清理旧报告
if os.path.exists(result_dir):
shutil.rmtree(result_dir)
if os.path.exists(report_dir):
shutil.rmtree(report_dir)
# 1. 运行 pytest 收集 allure 数据
print("---开始执行接口测试用例...")
ret = subprocess.call([
"pytest",
"testcases", # 或者指定单个文件 testcases/test_api.py
"--alluredir", result_dir
])
if ret != 0:
print("---用例执行有失败,请查看报告")
# 生成 html 报告
print("---生成 Allure 报告...")
subprocess.call([r"D:\allure-2.13.2\bin\allure.bat", "generate", result_dir, "-o", report_dir, "--clean"])
# 打开报告(可选)
print("---打开 Allure 报告...")
subprocess.call([r"D:\allure-2.13.2\bin\allure.bat", "open", report_dir])
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
run_pytest_with_allure()
print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dingyiaaa/ApiTestFramework.git
git@gitee.com:dingyiaaa/ApiTestFramework.git
dingyiaaa
ApiTestFramework
ApiTestFramework
master

搜索帮助