pytest solve the test case dependencies

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

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
Here Insert Picture Description
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

Published 92 original articles · won praise 43 · views 160 000 +

Guess you like

Origin blog.csdn.net/mayanyun2013/article/details/104560734