diff options
| author | Tim Graham <timograham@gmail.com> | 2012-10-10 20:03:27 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2012-10-10 20:03:27 -0400 |
| commit | 7ef2781ca0ce48872e21dce2f322c9e4106d1cfd (patch) | |
| tree | 4cc24b334ea61f5be66b1fdb2613e01a1c7add42 | |
| parent | f7b69665fd0ce21adae7cfaed7fade63f8aae1fd (diff) | |
Fixed #4501 - Documented how to use coverage.py with Django tests.
Thanks krzysiumed for the draft patch.
| -rw-r--r-- | docs/topics/testing.txt | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index e2d424aec5..f907c72a5e 100644 --- a/docs/topics/testing.txt +++ b/docs/topics/testing.txt @@ -589,6 +589,34 @@ to a faster hashing algorithm:: Don't forget to also include in :setting:`PASSWORD_HASHERS` any hashing algorithm used in fixtures, if any. +Integration with coverage.py +---------------------------- + +Code coverage describes how much source code has been tested. It shows which +parts of your code are being exercised by tests and which are not. It's an +important part of testing applications, so it's strongly recommended to check +the coverage of your tests. + +Django can be easily integrated with `coverage.py`_, a tool for measuring code +coverage of Python programs. First, `install coverage.py`_. Next, run the +following from your project folder containing ``manage.py``:: + + coverage run --source='.' manage.py test myapp + +This runs your tests and collects coverage data of the executed files in your +project. You can see a report of this data by typing following command:: + + coverage report + +Note that some Django code was executed while running tests, but it is not +listed here because of the ``source`` flag passed to the previous command. + +For more options like annotated HTML listings detailing missed lines, see the +`coverage.py`_ docs. + +.. _coverage.py: http://nedbatchelder.com/code/coverage/ +.. _install coverage.py: http://pypi.python.org/pypi/coverage + Testing tools ============= |
