-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
per file coverage threshold #691
Comments
Can you say more about what you want this to do? What would the user experience be? |
|
|
Thanks, that makes it clear. I'm not sure how this would help for your second case ("starting to do unit tests in a big project"): coverage would fail for a very long time, until you managed to get at least 10% (or whatever) coverage in every single file. That seems like it would be discouraging, and push you toward the wrong metric. |
Is there any ongoing action to implement |
Let's say I have 10 files, of which 9 of them are 100%, and one of them is 0%, and I set my limit to 90% coverage. Currently, it will pass because it's taking the average, but I don't want it to pass. That one file has below my coverage percentage of 90% so it should fail. When can we expect this feature? |
See also #717, which is similar. |
One option while waiting for coverage.py to add this as a feature: implement it as a separate tool. You can get a JSON report from coverage.py, and then check the totals for each file. This would be a way to experiment with different styles of rules also ("tests/" must have 100%, "project/" must have 90%, or whatever). |
I've written a proof-of-concept using the JSON report: https://github.com/nedbat/coveragepy/blob/master/lab/goals.py Try it and let me know what you think. |
... and a blog post about it: https://nedbatchelder.com/blog/202111/coverage_goals.html |
Looking forward to this feature! |
@RodriguezLucha you can get it now: https://nedbatchelder.com/blog/202111/coverage_goals.html Or is there a reason that isn't sufficient? |
@netbat I've ended up reimplementing different adhoc variants of this feature over the years and personally I think it would make a lot of since to include this inside coverage.py itself, to reduce number of dependencies and have a standardize way of doing it. I'm willing to help out with implementing & documenting this feature if you agree that it should go into coverage.py itself. |
It's easy to convince a team to just introduce a new configuration than a new file. 🤷♂️ I came across this issue 3 times already because I wanted to suggest it on different projects. But well... The script should be enough. I would not suggest it tho, because the weight of having that file does not overcome the need for this functionality on a project. But... If it was in the coverage itself, it's just a line of configuration. Anyway, I fully understand you. But if the feature was available on |
This was super helpful to enforce full coverage on our test files (and uncovered so broken tests in the process). Maybe as a middle ground, you could add this as a separate One piece of feedback (which I can open a PR for if you want) would be to use Line 78 in 3fac138
so that they show up better in some CI systems (Bamboo was initially hiding this in one of the output panes). |
This feature would be quite interesting to have in this tool by default. I very often realise I missed testing a whole file because I imported a function from another file (bad copy-paste obviously), and only when looking at the details of all the files and seeing a There are plenty of other tools in other languages that provide this by default, so why not here? |
The usual tradeoff of having to support code, and wondering how much use it would get. I suppose it wouldn't be much work to add a new command |
Do you have a suggestion on how to estimate that? I'd use it for uvicorn. 😬👍 |
The best we can do is gauge from comments on issues, and guess. |
If you can be more objective about what is needed to take a decision here, I can try to help... 👀 |
Thanks for the offer, but there is nothing more objective. We don't have a way to poll the users of coverage.py. |
I'm not sure if this is the same: How can I enforce 100% line coverage for test files in Python? |
I'll be interested to have this feature as well ! |
Também tenho interesse no tema ! |
Seria muito bom que a ferramenta desse suporte a isso, simplificando a vida, sem quer que re-implementar isso de forma ad hoc em vários projetos, para várias equipes |
I work on multiple projects where specific files have 100% coverage threshold. Unfortunately, copying If there are no plans to add a new command, I would like to create a separate Python package just for this script and slowly add other features if required. |
use cases:
The text was updated successfully, but these errors were encountered: