Use pytest-dependency resolution of dependencies between the use cases

Be used: Test B is only possible by effectively after the test A successfully.

image.png

Means: the use of a test plug may be labeled as dependent on other test when the dependency fails, the test will depend on it that are skipped.

-------------------------------------------------- ----------- on example: ------------------------------------ ----------------------------

Installation: pytest-dependency

pip install pytest-dependency


use:

import pytest

@pytest.mark.dependency()
def test_01(test):
    assert False

@pytest.mark.dependency(depends=["test_01"])
def test_02(test):
    print("执行测试2")

Look at the results:

image.png

test_01 test_02 dependent, and therefore fails after test_01, skipped test_02


in conclusion:

1, first install this plugin,

2, is the use of () depends on the labeling method @ pytest.mark.dependency, using @ pytest.mark.dependency (depends = [ "test_name"]) dependent reference.


Guess you like

Origin blog.51cto.com/9605182/2450589