import pytest """ids参数就是id,是一个可执行对象,用于生成测试id。或者一个列表、元组。指明所有新增用例的测试id。""" @pytest.mark.parametrize('input1, expected', [(1, 3), (2, 4)], ids=['case01', 'case02']) def test_one(input1, expected): assert input1+2 == expected @pytest.mark.parametrize('input1, expected', [(1, 3), (2, 4)], ids=["用例01", "用例02"]) def test_two(input1, expected): assert input1+2 == expected @pytest.mark.parametrize('input1, expected', [(1, 3), (2, 4)], ids=['001', '001']) def test_three(input1, expected): assert input1+2 == expected def ids_num(num): return num+1 @pytest.mark.parametrize('input1, expected', [(1, 3), (2, 4)], ids=ids_num) def test_four(input1, expected): assert input1+2 == expected # ids 最主要作业,进一步细化测试用例, @pytest.mark.parametrize('input1, expected', [ pytest.param(1, 3, id='case01'), pytest.param(2, 4, id='case02'), pytest.param(3, 6, id='case03'), ]) def test_four(input1, expected): assert input1+2 == expected pytest.main(["-q -rA", "05_ids参数_设置用例名称或id.py"])
pytest学习实践-day32: fixture学习11:数据驱动和参数传递-04:ids参数使用-设置用例的id
于 2024-04-11 09:19:10 首次发布