pytest running scenarios in the correct order in the class

陌路散爱 提交于 2019-12-02 04:35:17
hpk42

The upcoming pytest-2.3 has support for better (resource-based) ordering, and i just updated the scenario example in the docs: https://docs.pytest.org/en/latest/example/parametrize.html#a-quick-port-of-testscenarios

You can preliminary install the current development version with

pip install -i http://pypi.testrun.org -U pytest

and should get pytest-2.3.0.dev15 with "py.test --version" and be able to use it.

py.test runs tests in a distributed fashion, which means the order is essentially random.

You should use the -n option and set the process number to 1. Then tests should be run in alphabetical order by the single process spawned.

More than this I don't know if you can do. Anyway depending on the order of tests is generally bad design. So you should try to not depend on it at all.

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