Skip to content

Minimum coverage by group check#1105

Merged
sferik merged 1 commit intosimplecov-ruby:mainfrom
mikhliuk-k:minimum_coverage_by_group
Mar 28, 2026
Merged

Minimum coverage by group check#1105
sferik merged 1 commit intosimplecov-ruby:mainfrom
mikhliuk-k:minimum_coverage_by_group

Conversation

@mikhliuk-k
Copy link
Copy Markdown
Contributor

@mikhliuk-k mikhliuk-k commented Aug 29, 2024

I added support for coverage checking by group since we needed it for our project and noticed there was an open issue about it. This feature is useful as we’re gradually increasing test coverage across our app, so we can enforce coverage checks on specific parts. Here’s an example of how to use it from the README.

SimpleCov.minimum_coverage_by_group 'Models' => 80, 'Controllers' => 60
# same as above (the default is to check line coverage)
SimpleCov.minimum_coverage_by_group 'Models' => { line: 80 }, 'Controllers' => { line: 60 }
# check for a minimum line and branch coverage for 'Models' and 'Controllers' groups
SimpleCov.minimum_coverage_by_group 'Models' => { line: 90, branch: 80 }, 'Controllers' => { line: 60, branch: 50 }

@mikhliuk-k mikhliuk-k force-pushed the minimum_coverage_by_group branch from 37f41fc to 539a61f Compare September 2, 2024 21:43
@mikhliuk-k mikhliuk-k changed the title wip Minimum coverage by group check Sep 2, 2024
@mikhliuk-k mikhliuk-k force-pushed the minimum_coverage_by_group branch 4 times, most recently from ace4fb8 to 4846449 Compare September 2, 2024 22:31
@mikhliuk-k mikhliuk-k marked this pull request as ready for review September 2, 2024 22:45
@mikhliuk-k mikhliuk-k force-pushed the minimum_coverage_by_group branch from 4846449 to f17969d Compare September 2, 2024 22:56
@mikhliuk-k mikhliuk-k force-pushed the minimum_coverage_by_group branch from f17969d to c7835b5 Compare September 2, 2024 22:57
@coorasse
Copy link
Copy Markdown
Contributor

coorasse commented Sep 18, 2024

Lovely! This is also helpful when enabling the new coverage for eval. So we can enable coverage for erb files without dropping the global coverage.

@cb341
Copy link
Copy Markdown

cb341 commented Sep 27, 2024

This would be a very welcome change indeed!

@cb341
Copy link
Copy Markdown

cb341 commented Nov 18, 2024

Any updates regarding this pull request?

@jebentier
Copy link
Copy Markdown

@PragTob This additional functionality for setting minimum coverage by group would be very valuable. We're currently restructuring our Rails monolith to group functionality via Packwerk packages, allowing us to track overall coverage as well as per-package coverage separately via groups. Being able to systematically ratchet down coverage requirement on a per-package basis would be amazing. Would you mind looking into this PR?

@YegorZdanovich
Copy link
Copy Markdown

@PragTob @amatsuda hey guys, any chance it can be reviewed and merged?

@aguynamedben
Copy link
Copy Markdown

WANT

@viralpraxis
Copy link
Copy Markdown

That'd be an awesome feature.

@cb341
Copy link
Copy Markdown

cb341 commented Nov 6, 2025

What's the state of this PR?
Would be super cool

@denblackstache
Copy link
Copy Markdown

denblackstache commented Nov 12, 2025

Hey @amatsuda, what's blocking this PR from being merged?

Copy link
Copy Markdown
Collaborator

@sferik sferik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this is a great feature. The only issue I see is if a user specifies a in minimum_coverage_by_group that doesn't match any configured add_group, result.groups.fetch(group_name) will raise a KeyError with no helpful context. It should either raise a clear error message or warn and skip the missing group. There is also no test for this scenario.

That said, I’m happy to merge this patch as-is and fix that issue before shipping this feature. Thanks for the PR!

@sferik sferik merged commit 51ccdba into simplecov-ruby:main Mar 28, 2026
sferik added a commit that referenced this pull request Mar 28, 2026
Warn and skip instead of raising KeyError when a group name in
minimum_coverage_by_group doesn't match any configured add_group.

Follow-up to #1105.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants