语法:@pytest.mark.skip(reason=None)
说明:跳过执行测试用例,可选参数reason,跳过的原因,会在执行结果中打印。
用法:在类、方法或函数上添加@pytest.mark.skip
。
import pytest class Test_login(): def test_login_001(self): print("\n test login 001") @pytest.mark.skip(None) def test_login_002(self): print("\n test login 002") def test_login_003(self): print("\n test login 003") def test_login_004(self): print("\n test login 004")
执行结果:
import pytest x=11 class Test_login(): def test_login_001(self): print("\n test login 001") @pytest.mark.skip(None) def test_login_002(self): print("\n test login 002") def test_login_003(self): print("\n test login 003") @pytest.mark.skipif(x>10,reason="Num is large") def test_login_004(self): print("\n test login 004")
运行结果: