使用夹具scope = class实现pytest-rerun

时间:2019-04-12 06:47:17

标签: python pytest

我正在将pytest-rerun功能实现到pytest自动化脚本中。我的问题是它不适用于当前的pytest实现。详细地说,我在conftest文件中使用pytest Fixture scope = class,在其中设置测试环境,启动驱动程序。当我在类级别的脚本上实现pytest-rerun时,它没有第二次启动conftest.py文件。

尝试:-更改scope = session,它可以工作,但就我而言,我需要使用scope = session

# conftest file
@pytest.fixture(scope="class")
def test_setup(request):

    # specify app path from command line
    app_path = request.config.getoption("--app_path")
# automation file
@pytest.mark.usefixtures("test_setup")
class TestThreeinOneIndividual():

    @allure.severity(allure.severity_level.CRITICAL)  # mark test as a critical in report
    @pytest.mark.dependency(name="Login")
    def test_login(self, sanity_data):

预期: 每当pytest-rerun触发时,它将在conftest.py文件中重新运行自动化文件以及测试设置

0 个答案:

没有答案