1、首先安装测试框架和需要的插件
cmd 执行
$ pip install pytest-html
$ pip install pytest
2、然后我们在根目录建一个test开头的用例和report开头的目录,比如
3、在当前目录中执行
pytest --html=./report/report.html --self-contained-html
(html=./report/report.html是指报告存放的路径,–self-contained-html是指html文件中自带css样式)
生成测试报告位置:
报告样式:
重复执行测试用例:
首先安装插件:
pip install pytest-repeat
然后执行py.test --count=执行数量 用例文件,比如
py.test --count=10 test_01.py
如果觉得这样执行命令比较困难,我们也可以写一个py文件,好在IDE中直接执行
import os
#os.system(“pytest --html=./report/repzort.html --self-contained-html”)
os.system(“py.test --count=10 test_01.py”)
在实际中会方便一些