• 解决:
• 安装:pip install pytest-ordering
• 在测试方法上加下面装饰器
•@pytest.mark.last ---最后一个执行
• @pytest.mark.run(order=1)---第几个执行
pytest默认按字母顺序去执行的
import pytest
@pytest.mark.run(order=1)
def test_01():
print(‘test01‘)
@pytest.mark.run(order=2)
def test_02():
print(‘test01‘)
@pytest.mark.last
def test_06():
print(‘test01‘)
def test_04():
print(‘test01‘)
def test_05():
print(‘test01‘)
@pytest.mark.run(order=3)
def test_03():
print(‘test01‘)
pytest_order.py::test_01 PASSED [ 16%]test01
pytest_order.py::test_02 PASSED [ 33%]test01
pytest_order.py::test_03 PASSED [ 50%]test01
pytest_order.py::test_04 PASSED [ 66%]test01
pytest_order.py::test_05 PASSED [ 83%]test01
pytest_order.py::test_06 PASSED [100%]test01
原文:https://www.cnblogs.com/QaStudy/p/11567039.html