@pytest.mark.parametrize test case parameterization example explanation

 The @pytest.mark.parametrize decorator enables test case parameterization

@pytest.mark.parametrize("parameter name", list data)

Parameter name: used to receive each item of data and use it as a parameter of the test case

List data: a set of test data

 When @pytest.mark.parametrize() has only one parameter, each element of the list is passed in as a formal parameter, and the result of each execution will be asserted.

1. When passing a parameter, both ways of writing can be used. For details, see the following examples:

'''Writing one'''
@pytest.mark.parametrize('name',['lili','hello','sophia'])
def test_name(name):
print(name)



'''写法二'''
name_list=['lili','hello','sophia']
@pytest.mark.parametrize('name',name_list)
def test_name(name):
print (name)

二、传多个参数