Pytest @pytest.mark.parametrize装饰器
示例:
# -*- coding: utf-8 -*- ''' 业务逻辑相同,输入参数量较大, 使用 pyetst内置装饰器@pytest.mark.parametrize('参数名',参数列表) ''' import pytest @pytest.mark.parametrize('x,y',[(1,2),(3,4)]) def test_sum(x,y): sum = x+y print('\n') print(sum) if __name__ == '__main__': pytest.main(['test_scripts02.py','-s'])
控制台输出:
============================= test session starts ============================= platform win32 -- Python 3.8.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 rootdir: E:\PycharmProjects\Pytest-Webui-songqin plugins: allure-pytest-2.8.40, html-3.1.1, metadata-1.11.0 collected 2 items test_scripts02.py 3 . 7 . ============================== 2 passed in 0.09s ==============================
钟声敲响了日落,柏油路跃过山坡,一直通向北方的是我们想象,长大后也未曾经过~

浙公网安备 33010602011771号