summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJakub Paczkowski <jakub@paczkowski.eu>2015-11-07 14:57:56 +0100
committerTim Graham <timograham@gmail.com>2016-02-17 09:44:18 -0500
commitd4dc775620fc57e962165eab98a77264e3dd16b2 (patch)
treeef18bd2705ca738d087c4e725c489cffada1945d /docs
parent0db7e61076116c2d93d61f98ef31690542359e48 (diff)
Fixed #25735 -- Added support for test tags to DiscoverRunner.
Thanks Carl Meyer, Claude Paroz, and Simon Charette for review.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/django-admin.txt14
-rw-r--r--docs/releases/1.10.txt4
-rw-r--r--docs/topics/testing/tools.txt54
3 files changed, 72 insertions, 0 deletions
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 0fbad35bcf..87753b28bd 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -1348,6 +1348,20 @@ don't.
in order to exchange them between processes. See
:ref:`python:pickle-picklable` for details.
+.. option:: --tag TAGS
+
+.. versionadded:: 1.10
+
+Runs only tests :ref:`marked with the specified tags <topics-tagging-tests>`.
+May be specified multiple times and combined with :option:`test --exclude-tag`.
+
+.. option:: --exclude-tag EXCLUDE_TAGS
+
+.. versionadded:: 1.10
+
+Excludes tests :ref:`marked with the specified tags <topics-tagging-tests>`.
+May be specified multiple times and combined with :option:`test --tag`.
+
``testserver``
--------------
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index b3bd4b8afd..1154429f2b 100644
--- a/docs/releases/1.10.txt
+++ b/docs/releases/1.10.txt
@@ -336,6 +336,10 @@ Tests
* To better catch bugs, :class:`~django.test.TestCase` now checks deferrable
database constraints at the end of each test.
+* Tests and test cases can be :ref:`marked with tags <topics-tagging-tests>`
+ and run selectively with the new :option:`test --tag` and :option:`test
+ --exclude-tag` options.
+
URLs
~~~~
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 2bb53454cf..de008bd325 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -1622,6 +1622,60 @@ your test suite.
Person.objects.create(name="Aaron")
Person.objects.create(name="Daniel")
+.. _topics-tagging-tests:
+
+Tagging tests
+-------------
+
+.. versionadded:: 1.10
+
+You can tag your tests so you can easily run a particular subset. For example,
+you might label fast or slow tests::
+
+ from django.test.utils import tag
+
+ class SampleTestCase(TestCase):
+
+ @tag('fast')
+ def test_fast(self):
+ ...
+
+ @tag('slow')
+ def test_slow(self):
+ ...
+
+ @tag('slow', 'core')
+ def test_slow_but_core(self):
+ ...
+
+You can also tag a test case::
+
+ @tag('slow', 'core')
+ class SampleTestCase(TestCase):
+ ...
+
+Then you can choose which tests to run. For example, to run only fast tests:
+
+.. code-block:: console
+
+ $ ./manage.py test --tag=fast
+
+Or to run fast tests and the core one (even though it's slow):
+
+.. code-block:: console
+
+ $ ./manage.py test --tag=fast --tag=core
+
+You can also exclude tests by tag. To run core tests if they are not slow:
+
+.. code-block:: console
+
+ $ ./manage.py test --tag=core --exclude-tag=slow
+
+:option:`test --exclude-tag` has precedence over :option:`test --tag`, so if a
+test has two tags and you select one of them and exclude the other, the test
+won't be run.
+
.. _topics-testing-email:
Email services