[pytest] testpaths = ./test_case/test_params.py addopts = -vs --alluredir ./report
import pytest import requests from utils.read_yaml import get_yaml_data # 多个参数(’class1,class2‘,[('age','eat'),('age','eat')]) @pytest.mark.parametrize('title,body,userId',get_yaml_data()['lis']) def test_params(title,body,userId): HOST = 'ip' URL = '/posts/' url = HOST + URL json = { "title": title, "body": body, "userId": userId } res = requests.post(url, json=json) assert res.status_code==201
在终端里
pytest test_params.py # 执行py文件后生成一个report文件
allure serve report # 直接弹出浏览器打开报告