Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nedbat opened this issue Dec 19, 2013 · 5 comments
Labels
bug Something isn't working report

Comments

@nedbat
Copy link
Owner

nedbat commented Dec 19, 2013

Originally reported by Jon Dufresne (Bitbucket: jdufresne, GitHub: jdufresne)


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.


@nedbat
Copy link
Owner Author

nedbat commented Dec 22, 2013

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.

@nedbat
Copy link
Owner Author

nedbat commented Feb 4, 2014

Original comment by Jon Dufresne (Bitbucket: jdufresne, GitHub: jdufresne)


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.

@nedbat
Copy link
Owner Author

nedbat commented May 23, 2014

Original comment by Alexander Walters (Bitbucket: sdamon, GitHub: sdamon)


Or just use floor instead of round. 0.9999 would round to 100%, and floor to 99%, and would match the expectations of --fail-under.

@nedbat
Copy link
Owner Author

nedbat commented May 23, 2014

Original comment by Jon Dufresne (Bitbucket: jdufresne, GitHub: jdufresne)


Or just use floor instead of round. 0.9999 would round to 100%, and floor to 99%, and would match the expectations of --fail-under.

I like this idea. I created a pull request:

https://bitbucket.org/ned/coveragepy/pull-request/36/use-mathfloor-instead-of-round-when/diff

@nedbat
Copy link
Owner Author

nedbat commented Jun 4, 2014

Fixed in 0a9cb6a6fc61 (bb)

@nedbat nedbat closed this as completed Jun 4, 2014
@nedbat nedbat added major bug Something isn't working report labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working report
Projects
None yet
Development

No branches or pull requests

1 participant