Json report by Bachmann1234 · Pull Request #825 · nedbat/coveragepy (original) (raw)

venv ❯ coverage --help
Coverage.py, version 5.0a7 with C extension
Measure, collect, and report on code coverage in Python programs.

usage: coverage <command> [options] [args]

Commands:
    annotate    Annotate source files with execution information.
    combine     Combine a number of data files.
    erase       Erase previously collected coverage data.
    help        Get help on using coverage.py.
    html        Create an HTML report.
    json        Create a JSON report of coverage results.
    report      Report coverage stats on modules.
    run         Run a Python program and measure code execution.
    xml         Create an XML report of coverage results.

Use "coverage help <command>" for detailed help on any command.
Full documentation is at https://coverage.readthedocs.io/en/coverage-5.0a7
venv ❯ coverage json --help
Usage: coverage json [options] [modules]

Generate a JSON report of coverage results.

Options:
  --fail-under=MIN      Exit with a status of 2 if the total coverage is less
                        than MIN.
  -i, --ignore-errors   Ignore errors while reading source files.
  --include=PAT1,PAT2,...
                        Include only files whose paths match one of these
                        patterns. Accepts shell-style wildcards, which must be
                        quoted.
  --omit=PAT1,PAT2,...  Omit files whose paths match one of these patterns.
                        Accepts shell-style wildcards, which must be quoted.
  -o OUTFILE            Write the JSON report to this file. Defaults to
                        'coverage.json'
  --pretty-print        Print the json formatted for human readers
  --show-contexts       Show contexts for covered lines.
  --contexts=PAT1,PAT2,...
                        Only display data from lines covered in the given
                        contexts. Accepts shell-style wildcards, which must be
                        quoted.
  --debug=OPTS          Debug options, separated by commas. [env:
                        COVERAGE_DEBUG]
  -h, --help            Get help on this command.
  --rcfile=RCFILE       Specify configuration file. By default '.coveragerc',
                        'setup.cfg' and 'tox.ini' are tried. [env:
                        COVERAGE_RCFILE]

Full documentation is at https://coverage.readthedocs.io/en/coverage-5.0a7
{
    "meta": {
        "version": "5.0a7",
        "timestamp": "2019-08-18T13:50:07.353011",
        "branch_coverage": true,
        "show_contexts": false
    },
    "files": {
        "a.py": {
            "executed_lines": [
                1,
                2
            ],
            "summary": {
                "covered_lines": 2,
                "num_statements": 3,
                "percent_covered": 60.0,
                "missing_lines": 1,
                "excluded_lines": 0,
                "num_branches": 2,
                "num_partial_branches": 1
            },
            "missing_lines": [
                3
            ],
            "excluded_lines": []
        }
    },
    "totals": {
        "covered_lines": 2,
        "num_statements": 3,
        "percent_covered": 60.0,
        "missing_lines": 1,
        "excluded_lines": 0,
        "num_branches": 2,
        "num_partial_branches": 1
    }
}