使用方法:

@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("不跳过")

  pytest跳过测试函数

 

相关文章:

  • 2022-03-04
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-07
  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案