summaryrefslogtreecommitdiff
path: root/docs/topics/testing
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2021-04-24 16:46:16 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-07-08 07:29:04 +0200
commit90ba716bf060ee7fef79dc230b0b20644839069f (patch)
tree93ac388d4c3a75e5ab34edbf5a552305b72962d4 /docs/topics/testing
parent77b88fe621bb7828535a4c4cf37d9d4ac01b146b (diff)
Fixed #24522 -- Added a --shuffle option to DiscoverRunner.
Diffstat (limited to 'docs/topics/testing')
-rw-r--r--docs/topics/testing/advanced.txt17
-rw-r--r--docs/topics/testing/overview.txt6
2 files changed, 18 insertions, 5 deletions
diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt
index a8a63e7b57..dcc1be7f44 100644
--- a/docs/topics/testing/advanced.txt
+++ b/docs/topics/testing/advanced.txt
@@ -510,7 +510,7 @@ behavior. This class defines the ``run_tests()`` entry point, plus a
selection of other methods that are used by ``run_tests()`` to set up, execute
and tear down the test suite.
-.. class:: DiscoverRunner(pattern='test*.py', top_level=None, verbosity=1, interactive=True, failfast=False, keepdb=False, reverse=False, debug_mode=False, debug_sql=False, parallel=0, tags=None, exclude_tags=None, test_name_patterns=None, pdb=False, buffer=False, enable_faulthandler=True, timing=True, **kwargs)
+.. class:: DiscoverRunner(pattern='test*.py', top_level=None, verbosity=1, interactive=True, failfast=False, keepdb=False, reverse=False, debug_mode=False, debug_sql=False, parallel=0, tags=None, exclude_tags=None, test_name_patterns=None, pdb=False, buffer=False, enable_faulthandler=True, timing=True, shuffle=False, **kwargs)
``DiscoverRunner`` will search for tests in any file matching ``pattern``.
@@ -539,7 +539,8 @@ and tear down the test suite.
If ``reverse`` is ``True``, test cases will be executed in the opposite
order. This could be useful to debug tests that aren't properly isolated
and have side effects. :ref:`Grouping by test class <order-of-tests>` is
- preserved when using this option.
+ preserved when using this option. This option can be used in conjunction
+ with ``--shuffle`` to reverse the order for a particular random seed.
``debug_mode`` specifies what the :setting:`DEBUG` setting should be
set to prior to running tests.
@@ -576,6 +577,14 @@ and tear down the test suite.
If ``timing`` is ``True``, test timings, including database setup and total
run time, will be shown.
+ If ``shuffle`` is an integer, test cases will be shuffled in a random order
+ prior to execution, using the integer as a random seed. If ``shuffle`` is
+ ``None``, the seed will be generated randomly. In both cases, the seed will
+ be logged to the console and set to ``self.shuffle_seed`` prior to running
+ tests. This option can be used to help detect tests that aren't properly
+ isolated. :ref:`Grouping by test class <order-of-tests>` is preserved when
+ using this option.
+
Django may, from time to time, extend the capabilities of the test runner
by adding new arguments. The ``**kwargs`` declaration allows for this
expansion. If you subclass ``DiscoverRunner`` or write your own test
@@ -590,6 +599,10 @@ and tear down the test suite.
The ``enable_faulthandler`` and ``timing`` arguments were added.
+ .. versionadded:: 4.0
+
+ The ``shuffle`` argument was added.
+
Attributes
~~~~~~~~~~
diff --git a/docs/topics/testing/overview.txt b/docs/topics/testing/overview.txt
index 7461fdaaf0..cc55224761 100644
--- a/docs/topics/testing/overview.txt
+++ b/docs/topics/testing/overview.txt
@@ -235,9 +235,9 @@ the Django test runner reorders tests in the following way:
for quicker feedback. This includes things like test modules that couldn't
be found or that couldn't be loaded due to syntax errors.
-You may reverse the execution order inside groups using the :option:`test
---reverse` option. This can help with ensuring your tests are independent from
-each other.
+You may randomize and/or reverse the execution order inside groups using the
+:option:`test --shuffle` and :option:`--reverse <test --reverse>` options. This
+can help with ensuring your tests are independent from each other.
.. versionchanged:: 4.0