From http://coverage.readthedocs.io/en/coverage-4.3.4/cmd.html the coverage analysis report is done by:
$ coverage report -m
Name Stmts Miss Cover Missing
-------------------------------------------------------
my_program.py 20 4 80% 33-35, 39
my_module.py 15 2 86% 8, 12
my_other_module.py 56 6 89% 17-23
-------------------------------------------------------
TOTAL 91 12 87%
But, what is a statement ("Stmts") in this tool?
The coverage.py Python module provides statement coverage for Python. It accumulates coverage data over many runs; generates coverage reports; and annotates Python source showing which statements have been covered.
An Intro to coverage.py. Coverage.py is a 3rd party tool for Python that is used for measuring your code coverage. It was originally created by Ned Batchelder. The term “coverage” in programming circles is typically used to describe the effectiveness of your tests and how much of your code is actually covered by tests.
Statement coverage is the weakest measure of code coverage. It can't tell you when an if statement is missing an else clause ("branch coverage"); when a condition is only tested in one direction ("condition coverage"); when a loop is always taken and never skipped ("loop coverage"); and so on.
Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been executed, then analyzes the source to identify code that could have been executed but was not.
I realized that statements are the number of lines of code including imports, class and function definitions (not counting the comments).
Stmts
is the number of total statements. For example, for the first line, 20 statements were executed, out of which 4 were missed, so 16 were covered:
16/20 = 0.8 (80%)
which matches the 80%
cover ratio in the table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With