Be used: Test B is only possible by effectively after the test A successfully.
This plug may be labeled as a test independent of 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")
The results
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.
https://blog.51cto.com/9605182/2450589?source=drt