ui自动化框架出测试报告

1.防止jenkis集成报错

import subprocess

2.subprocess.call  shell=true 会有延迟时间让用例一条一条跑,手动点击停止

防止python脚本执行完之后,jenkis没有生成测试报告

专门负责出测试报告的模块  allure 模块 pytest专门出测试用例 

1.解压文件
2.将解压bin 目录放到系统环境变量path 下
3.allure --version cmd输入
4.python 安装 pip install allure-pytest

5.在每一个test开头的用例中添加描述

ui自动化框架出测试报告


@allure.story('登录')#模块
@allure.title('反案例登录')
@allure.description('第二个案例')#描述
也可以添加地址 一个指向bug 一个指向测试用例
6.run调用的优化
import pytest
import time
import subprocess #引入模块


if __name__ == '__main__':
report_time = time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time()))#转成时间戳
pytest.main(['-s', './cases/',f'--alluredir=report/{report_time}/json/'])
#自动调用
import pytest
import time
import subprocess

if __name__ == '__main__':
report_time = time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time()))
pytest.main(['-s', './cases/',f'--alluredir=report/{report_time}/json/'])
subprocess.call(
f'G://a-刘泽老师视频/ui自动化/ui自动化/出测试报告/allure-commandline-2.13.3/allure-2.13.3/bin/allure generate report/{report_time}/json/ -o report/{report_time}/html/',
shell=True)
allure generate report/{report_time}/json/ -o report/{report_time}/html/ 实际实在cmd窗口里跑,这样不智能了所以引入了
subprocess.call 就是引入shell脚本的命令