@@ -483,3 +483,36 @@ Although multiple test order markers create their own parametrization, it can be
483483 test_multiple_markers.py::test_two_and_four[index=4-bbb] PASSED [ 87%]
484484 test_multiple_markers.py::test_two_and_four[index=4-ccc] PASSED [100%]
485485 ============================== 8 passed in 0.02s ==============================
486+
487+
488+ Ordering test modules
489+ ---------------------
490+
491+ Sometimes you want to order whole test modules instead of single tests.
492+ This may be the case if you are testing several steps of a workflow, where each step
493+ has a number of independent tests in the same test module, but the test modules have
494+ to be executed in a certain order, because the workflow steps depend on each other,
495+ as is for example the case with testing a set of API endpoints.
496+
497+ In this case, instead of using the module :ref: `order-scope ` and marking single tests,
498+ you can just mark the whole test module with the same marker using ``pytestmark `` in each
499+ of the concerned test modules:
500+
501+ .. code :: python
502+
503+ import pytest
504+
505+ pytestmark = pytest.mark.order(1 )
506+
507+
508+ def test_1 ():
509+ ...
510+
511+ In this case, all tests in the module will have the same order marker. As the test order
512+ is not changed for tests with the same order number, the tests *inside * each module will be run
513+ in the same order as without any ordering. The order of the test module execution, however,
514+ now depends on the defined ``pytestmark ``. No extra command line argument is needed in this case.
515+
516+ Modules will be ordered the same way as single tests with order markers: first the modules with
517+ an order marker >= 0 will be executed in ascending marker order, afterwards all modules without order
518+ markers in the same order as without ordering, and finally any modules with a negative order marker.
0 commit comments