summaryrefslogtreecommitdiff
path: root/docs/topics/testing
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/topics/testing
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/topics/testing')
-rw-r--r--docs/topics/testing/tools.txt54
1 files changed, 54 insertions, 0 deletions
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