pytest跳过指定的测试或模块

最后都变了- 提交于 2019-11-27 16:07:09

参考pytest常见用法pytest官方文档

1.运行带指定标记的测试

@pytest.mark.tags ,这里的tags可以自定义

命令行执行:pytest -v -m 'tags' 

2.跳过指定的测试

@pytest.mark.skip(reason="过期")#跳过该测试
def test_app_logic():
    '''
    用例描述:逻辑测试
    '''
    print('逻辑测试')
    time.sleep(1)
    assert 1==1

3.跳过指定的模块

实际测试时,当 @pytest.importorskip("模块名",minversion="1.5")这个装饰器在哪个模块,哪个模块就会被跳过,模块名随便写都没影响。

@pytest.importorskip("test_ltcs",minversion="1.5")
@allure.step('检查UI名:{0}打开了')
def ui_check(tips):
    return tips

4.条件跳过指定的用例

@pytest.mark.skipif(条件) 

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!