1

我需要组织我的测试用例,因为我有一个大型测试套件。如果在另一个 Python 类中依赖的测试失败,我看不到要跳过一个 Python 类中的测试。

这是我的基本设置:

class TestWorkflow1:

    @staticmethod
    @pytest.mark.dependency()
    def test_create_something():
        //do some stuff    

class TestNegativeWorkflowClone1:

    @staticmethod
    @pytest.mark.dependency('TestWorkflow1::test_create_something')
    def test_try_to_clone_something():
        //do some stuff 

TestNegativeWorkflowClone1之前运行TestWorkflow1。我已经尝试过此票的答案中建议的内容:Dependencies between files with pytest-dependency?

from pytest_dependency import DependencyManager

class TestWorkflow1:
    DependencyManager.ScopeCls['module'] = DependencyManager.ScopeCls['session']

    @staticmethod
    @pytest.mark.dependency()
    def test_create_something():
        //do some stuff    

from pytest_dependency import DependencyManager

class TestNegativeWorkflowClone1:
    DependencyManager.ScopeCls['module'] = DependencyManager.ScopeCls['session']

    @staticmethod
    @pytest.mark.dependency('TestWorkflow1::test_create_something')
    def test_try_to_clone_something():
        //do some stuff 

那也没有用。TestNegativeWorkflowClone1仍然运行之前TestWorkflow1

我尝试在依赖装饰中使用文件名TestNegativeWorkflowClone1

class TestNegativeWorkflowClone1:
    DependencyManager.ScopeCls['module'] = DependencyManager.ScopeCls['session']

    @staticmethod
    @pytest.mark.dependency('TestWorkflow1.py::test_create_something')
    def test_try_to_clone_something():
        //do some stuff 

仍然没有工作。TestNegativeWorkflowClone1仍然先运行。

4

0 回答 0