pytest 参数化

发布时间 2023-08-02 20:55:42作者: 胖豆芽
import pytest

# 多个参数(’class1,class2‘,[('age','eat'),('age','eat')])
@pytest.mark.parametrize('dog,cat',[('2','bone'),('1','fish')])
def test_params(dog,cat):
    assert 1==1

 

Testing started at 20:43 ...
Launching pytest with arguments test_params.py::test_params --no-header --no-summary -q in D:\pythonProject0726\test_case

============================= test session starts =============================
collecting ... collected 2 items

test_params.py::test_params[2-bone] PASSED                               [ 50%]
test_params.py::test_params[1-fish] PASSED                               [100%]

============================== 2 passed in 0.01s ==============================

Process finished with exit code 0