diff options
author | Matt Bachmann <bachmann.matt@gmail.com> | 2019-07-08 23:09:38 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-08-31 07:24:08 -0400 |
commit | 9a78a80aaf8f8161b857ebf3cf02dd511181dd07 (patch) | |
tree | d73603d17fc5269a3b8199085bf67c436d99aedf /doc | |
parent | 790f0b30010a3a1f68f4fa7c172ce3b31c7c4b24 (diff) | |
download | python-coveragepy-git-9a78a80aaf8f8161b857ebf3cf02dd511181dd07.tar.gz |
Create a JSON report
Diffstat (limited to 'doc')
-rw-r--r-- | doc/branch.rst | 5 | ||||
-rw-r--r-- | doc/cmd.rst | 17 | ||||
-rw-r--r-- | doc/config.rst | 19 | ||||
-rw-r--r-- | doc/howitworks.rst | 4 | ||||
-rw-r--r-- | doc/source.rst | 10 |
5 files changed, 45 insertions, 10 deletions
diff --git a/doc/branch.rst b/doc/branch.rst index 92cab27b..9af8f050 100644 --- a/doc/branch.rst +++ b/doc/branch.rst @@ -55,8 +55,9 @@ The HTML report gives information about which lines had missing branches. Lines that were missing some branches are shown in yellow, with an annotation at the far right showing branch destination line numbers that were not exercised. -The XML report produced by ``coverage xml`` also includes branch information, -including separate statement and branch coverage percentages. +The XML and JSON reports produced by ``coverage xml`` and ``coverage json`` +respectively also include branch information, including separate statement and +branch coverage percentages. How it works diff --git a/doc/cmd.rst b/doc/cmd.rst index 42738493..ad84a6ae 100644 --- a/doc/cmd.rst +++ b/doc/cmd.rst @@ -22,6 +22,7 @@ Coverage.py command line usage .. :history: 20121117T091000, Added command aliases. .. :history: 20140924T193000, Added --concurrency .. :history: 20150802T174700, Updated for 4.0b1 +.. :history: 20190828T212200, added json report .. highlight:: console @@ -41,6 +42,8 @@ Coverage.py has a number of commands which determine the action performed: * **html** -- Produce annotated HTML listings with coverage results. +* **json** -- Produce a JSON report with coverage results. + * **xml** -- Produce an XML report with coverage results. * **annotate** -- Annotate source files with coverage results. @@ -292,7 +295,8 @@ Reporting --------- Coverage.py provides a few styles of reporting, with the **report**, **html**, -**annotate**, and **xml** commands. They share a number of common options. +**annotate**, **json**, and **xml** commands. They share a number of common +options. The command-line arguments are module or file names to report on, if you'd like to report on a subset of the data collected. @@ -473,6 +477,17 @@ You can specify the name of the output file with the ``-o`` switch. Other common reporting options are described above in :ref:`cmd_reporting`. +.. _cmd_json: + +JSON reporting +------------- + +The **json** command writes coverage data to a "coverage.json" file. + +You can specify the name of the output file with the ``-o`` switch. + +Other common reporting options are described above in :ref:`cmd_reporting`. + .. _cmd_debug: diff --git a/doc/config.rst b/doc/config.rst index 35584f01..84c77131 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -301,3 +301,22 @@ also apply to XML output, where appropriate. identified as packages in the report. Directories deeper than this depth are not reported as packages. The default is that all directories are reported as packages. + +.. _config_json: + +[json] +----- + +Values particular to json reporting. The values in the ``[report]`` section +also apply to JSON output, where appropriate. + +``json_output`` (string, default "coverage.json"): where to write the json +report. + +``json_pretty_print`` (boolean, default false): controls if fields in the json +are outputted with whitespace formatted for human consumption (True) or for +minimum file size (False) + +``json_show_contexts`` (boolean, default false): should the json report include +an indication on each line of which contexts executed the line. +See :ref:`dynamic_contexts` for details. diff --git a/doc/howitworks.rst b/doc/howitworks.rst index 62af42e3..0e11c29e 100644 --- a/doc/howitworks.rst +++ b/doc/howitworks.rst @@ -83,8 +83,8 @@ Reporting Once we have the set of executed lines and missing lines, reporting is just a matter of formatting that information in a useful way. Each reporting method -(text, html, annotated source, xml) has a different output format, but the -process is the same: write out the information in the particular format, +(text, html, json, annotated source, xml) has a different output format, but +the process is the same: write out the information in the particular format, possibly including the source code itself. diff --git a/doc/source.rst b/doc/source.rst index e1bc8038..21a5f612 100644 --- a/doc/source.rst +++ b/doc/source.rst @@ -80,11 +80,11 @@ reported. Usually you want to see all the code that was measured, but if you are measuring a large project, you may want to get reports for just certain parts. -The report commands (``report``, ``html``, ``annotate``, and ``xml``) all take -optional ``modules`` arguments, and ``--include`` and ``--omit`` switches. The -``modules`` arguments specify particular modules to report on. The ``include`` -and ``omit`` values are lists of file name patterns, just as with the ``run`` -command. +The report commands (``report``, ``html``, ``json``, ``annotate``, and ``xml``) +all take optional ``modules`` arguments, and ``--include`` and ``--omit`` +switches. The ``modules`` arguments specify particular modules to report on. +The ``include`` and ``omit`` values are lists of file name patterns, just as +with the ``run`` command. Remember that the reporting commands can only report on the data that has been collected, so the data you're looking for may not be in the data available for |