Issue #284 resolved

fail-under should show more precision; confusing when just a small value below threshold

Jon Dufresne
created an issue

If the test coverage is just a small fraction below the fail-under value, the report will fail with a non-zero exit status (good and expected) but the report appears as if everything is ok. As an example I received the following report:

$ coverage report --fail-under=70
Name                                    Stmts   Miss  Cover   Missing
---------------------------------------------------------------------
...  
---------------------------------------------------------------------
TOTAL                                    1816    551    70%   
$ echo $?
2

Doing the math:

>>> (1816.0 - 551.0) / 1816.0
0.6965859030837004

This is indeed below 70%. However at first glance, coverage reports this as 70% coverage (due to rounding I assume) creating confusion for me the user. In the case of failure, I would like to see report provide a more precise number for coverage so that the failure is immediately obvious.

Comments (5)

  1. Ned Batchelder repo owner

    Hmm, it seems odd to me to change the reporting based on whether --fail-under is used or not. Better I think would be to use the rounded number in the fail-under calculation.

  2. Jon Dufresne reporter

    Hmm, it seems odd to me to change the reporting based on whether --fail-under is used or not. Better I think would be to use the rounded number in the fail-under calculation.

    Sure. I think this solution makes sense and would remove the confusion.

  3. Log in to comment