Skip to content
Latchkey

SimpleCov "Line coverage is below the expected minimum" in CI

SimpleCov enforces minimum_coverage at the end of the test run. When line (or branch) coverage is below the set minimum, it prints the shortfall and sets a non-zero exit status, failing the CI job.

What this error means

After RSpec/Minitest finishes, SimpleCov prints "SimpleCov failed with exit 2 due to a coverage related error" and "Line coverage (72.5%) is below the expected minimum coverage (80.00%)."

simplecov
Coverage report generated for RSpec to /app/coverage. 72.5% covered.
Line coverage (72.5%) is below the expected minimum coverage (80.00%).
SimpleCov failed with exit 2 due to a coverage related error.

Common causes

Coverage fell below minimum_coverage

New untested code lowered line or branch coverage under the value configured in the SimpleCov block.

Parallel or multi-suite runs not merged

Split test suites each write partial results; without merging, the measured percentage is lower than the true total and trips the gate.

How to fix it

Add tests or set a realistic minimum

  1. Open coverage/index.html to find the uncovered files and lines.
  2. Add tests for the gaps.
  3. If the bar is too high for now, set minimum_coverage to the honest current level and raise it over time.
spec/spec_helper.rb
# spec/spec_helper.rb
require 'simplecov'
SimpleCov.start do
  minimum_coverage line: 80, branch: 70
end

Merge results from split suites

Use a shared command_name per suite and let SimpleCov merge results so the total is computed across all of them.

spec/spec_helper.rb
SimpleCov.start do
  command_name "Job#{ENV['CI_NODE_INDEX']}"
end

How to prevent it

  • Run the suite with SimpleCov locally before pushing.
  • Merge coverage from parallel jobs before evaluating the minimum.
  • Raise minimum_coverage incrementally as coverage improves.

Frequently asked questions

What causes ""coverage is below the expected minimum""?
New untested code lowered line or branch coverage under the value configured in the SimpleCov block.
How do I fix "coverage is below the expected minimum"?
Add tests or set a realistic minimum

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card