目录:导读
前言
第一种:通过yaml文件获取数据(一维列表)
data.yaml文件内容如下:
- '软件测试'
- '单元测试'
- '自动化测试'
- '性能测试'
- '测试开发'
- '测试架构师'
测试用例内容如下:
@pytest.mark.parametrize('data', yaml.load(open('data.yml', 'r')))
def test_ddt(data):
url='https://www.baidu.com/search/query?key='
header = {
'Accept': "application/json",
'Content-Type': "application/json; charset=utf-8",
'Accept-Encoding': "gzip, deflate, br"}
res=requests.get(url+data, header)
assert res.status_code==200
第二种:通过yaml文件获取数据(二维列表)
data.yaml文件内容如下:
#用例1
-
api_name: page_title
url: http://www.baidu.com/
header = {
'Accept': "application/json",
'Content-Type': "application/json; charset=utf-8",
'Accept-Encoding': "gzip, deflate, br"}
data: {
"status_code": 200
}
#用例2
-
api_name: searching
url: http: