addopts = -vs 配置默认携带的参数
testpaths = ./basics 配置默认执行用例的目录
配置用例分组的便签名
markers =
smoke:冒烟用例
huigui:回归用例
@pytest.mark.run(order=1)
这条只属于冒烟用例
@pytest.mark.smoke
def test1():
print('登录')
@pytest.mark.run(order=4)
def test4():
print('取件')
@pytest.mark.skip(reason="说明跳过原因")
def test_skip():
print("测试跳过这条用例")
这条被设置为2个分组,属于冒烟和回归
@pytest.mark.run(order=2)
@pytest.mark.huigui
@pytest.mark.smoke
def test2():
print('存件')
age=17
@pytest.mark.run(order=3)
这条只属于冒烟用例
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason="未成年人不需要发短信")
def test3():
print('发短信')
pytest.main([r'D:\python新代码集\pytest_study\basics\test_execution_sequence.py','-m smoke'])
pytest.main([r'D:\python新代码集\pytest_study\basics\test_execution_sequence.py','-m huigui'])
pytest.main([r'D:\python新代码集\pytest_study\basics\test_execution_sequence.py','-m huigui and smoke'])
pytest.main([r'D:\python新代码集\pytest_study\basics\test_execution_sequence.py','-m huigui or smoke'])
@pytest.mark.skip(reason="说明跳过原因")
def test_skip():
print("测试跳过这条用例")
age=17
@pytest.mark.run(order=3)
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason="未成年人不需要发短信")
def test3():
print('发短信')
@pytest.mark.run(order=1)
@pytest.mark.smoke
def test1():
print('登录')
@pytest.mark.run(order=4)
def test4():
print('取件')
@pytest.mark.skip(reason="说明跳过原因")
def test_skip():
print("测试跳过这条用例")
@pytest.mark.run(order=2)
@pytest.mark.huigui
@pytest.mark.smoke
def test2():
print('存件')
age=17
@pytest.mark.run(order=3)
@pytest.mark.huigui
@pytest.mark.skipif(age<18,reason="未成年人不需要发短信")
def test3():
print('发短信')