I have this result from running coverage, and I can't for the life of me figure out how the coverage percentages are calculated..?
In this example it explains branch coverage, but doesn't say anything about coverage percentages for the example.
update: here are the details for pfind.py:
coverage
is counting each branch as two possible instructions and giving them the same weight as non-branching instructions. Using this formula:
Looking at results.py
from the code, the coverage percentage is calculated in pc_covered
, with the data obtained from ratio_covered
function:
@property
def ratio_covered(self):
"""Return a numerator and denominator for the coverage ratio."""
numerator = self.n_executed + self.n_executed_branches
denominator = self.n_statements + self.n_branches
return numerator, denominator
As you can see, if branch coverage is enabled each branch will be accounted twice, once as a statement and once as a branch.
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