繁体   English   中英

[py.test]: 测试依赖

[英][py.test]: test dependencies

我正在使用 py.test 编写测试系统,并寻找一种方法来根据其他一些测试运行结果执行特定测试。

比如我们有标准测试class:

import pytest

class Test_Smoke:
   def test_A(self):
       pass

   def test_B(self):
       pass

   def test_C(self):
       pass

如果通过了 test_A() 和 test_B(),则应执行 test_C(),否则跳过。

我需要一种方法在测试或测试 class 级别上执行类似的操作(例如,如果所有 Test_Smoke 通过,则执行 Test_Perfo),并且我无法使用标准方法(如 @pytest.mark.skipif)找到解决方案。

pytest 有可能吗?

你可能想看看pytest-dependency 它是一个插件,允许您跳过一些测试,如果其他测试失败。

还考虑pytest-depends

def test_build_exists():
    assert os.path.exists(BUILD_PATH)

@pytest.mark.depends(on=['test_build_exists'])
def test_build_version():
    # this will skip if `test_build_exists` fails...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM