From 22fe2eb167a18dda8fd3e14cbf9166a1c7331fb9 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 29 May 2021 12:54:00 -0400 Subject: doc: mention dynamic contexts in more places --- doc/faq.rst | 12 ++++++++++++ doc/index.rst | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'doc') diff --git a/doc/faq.rst b/doc/faq.rst index 082ccbd1..0fce8903 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -50,6 +50,18 @@ reported. If you collect execution data on Python 3.7, and then run coverage reports on Python 3.8, there will be a discrepancy. +Q: Can I find out which tests ran which lines? +.............................................. + +Yes! Coverage.py has a feature called :ref:`dynamic_contexts` which can collect +this information. Add this to your .coveragerc file:: + + [run] + dynamic_context = test_function + +and then use the ``--contexts`` option when generating an HTML report. + + Q: How is the total percentage calculated? .......................................... diff --git a/doc/index.rst b/doc/index.rst index a06ad1b6..13c25ca1 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -137,6 +137,24 @@ Getting started is easy: .. _report like this one: https://nedbatchelder.com/files/sample_coverage_html_beta/index.html +Capabilities +------------ + +Coverage.py can do a number of things: + +- By default it will measure line (statement) coverage. + +- It can also measure :ref:`branch coverage `. + +- It can tell you :ref:`what tests ran which lines `. + +- It can produce reports in a number of formats: :ref:`text `, + :ref:`HTML `, :ref:`XML `, and :ref:`JSON `. + +- For advanced uses, there's an :ref:`API `, and the result data is + available in a :ref:`SQLite database `. + + Using coverage.py ----------------- -- cgit v1.2.1