Be used: Test B is only possible by effectively after the test A successfully.
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:
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.