@@ -653,6 +653,36 @@ If you use the option `--error-on-failed-ordering`, "test_two" will now error:
653653 ERROR test_failed_ordering.py::test_two - Failed: The test could not be ordered
654654 ========================= 1 passed, 1 error in 0.75s ==========================
655655
656+ ``--fail-all-on-failed-ordering ``
657+ ---------------------------------
658+ This option is analogous to ``--error-on-failed-ordering ``, but instead of failing only
659+ the tests that could not be ordered, it aborts the whole test run immediately, without
660+ executing any tests. This is useful if running the tests in a wrong order has
661+ unwanted effects.
662+
663+ Using the example shown above::
664+
665+ $ pytest tests -vv --fail-all-on-failed-ordering
666+ ============================= test session starts ==============================
667+ ...
668+ collected 2 items
669+
670+ ============================ no tests ran in 0.02s =============================
671+ ERROR: pytest-order: cannot execute 'test_two' relative to others: 'test_three'
672+
673+ The test run exits with the usage error exit code (4).
674+
675+ The option also works with ``--collect-only ``, as the ordering happens during test
676+ collection. This allows validating the ordering, e.g. in CI, without executing any
677+ tests::
678+
679+ $ pytest tests --collect-only --fail-all-on-failed-ordering
680+ ERROR: pytest-order: cannot execute 'test_two' relative to others: 'test_three'
681+ ============================= test session starts ==============================
682+ ...
683+ ========================== 2 tests collected in 0.01s ==========================
684+
685+ The exit code is 4 in this case as well, and 0 if all tests could be ordered.
656686
657687
658688.. _`pytest-dependency` : https://pypi.org/project/pytest-dependency/
0 commit comments