; ;

pytest跳过测试函数

使用方法:

@pytest.mark.skipif(condition,reason=None)

 

参数:

         condition:跳过的条件,True(跳过、不执行)/False(不跳过、执行),必传参数

         reason:标注原因

class test_skip:
    n=5
    @pytest.mark.skipif(2 > 1, reason="如果条件为false就跳过")
    def test_a(self):
        print("跳过")
    def test_b(self):
        print("不跳过")
    @pytest.mark.skipif(n > 6, reason="如果条件为false就跳过")   # 条件为boolean值,True(跳过)/False(不跳过/执行)
    def test_c(self):
        print("不跳过")

  

 

posted @ 2020-04-04 22:32  做梦的人-  阅读(462)  评论(0编辑  收藏  举报