A Nose plugin to specify the order of unit test execution

▼魔方 西西 提交于 2019-11-29 05:47:30

From the documentation:

[...] nose runs functional tests in the order in which they appear in the module file. TestCase-derived tests and other test classes are run in alphabetical order.

So a simple solution might be to rename the tests in your test case:

class Foo(unittest.TestCase):

    def test_01_foo(self):
        pass

    def test_02_boo(self):
        pass

I found a solution for it using PyTest ordering plugin provided here.

Try py.test YourModuleName.py -vv in CLI and the test will run in the order they have appeared in your module (first test_foo and then test_bar)

I did the same thing and works fine for me.

Note: You need to install PyTest package and import it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!