covered icon indicating copy to clipboard operation
covered copied to clipboard

Minitest exit value

Open everton opened this issue 1 year ago • 4 comments

To incorporate this gem as part of a CI process, the tests suite should return a non-success exit code when coverage failed.

For minitest, ignoring thresholds (considering anything bellow 100% a failure), this block inside the minitest.rb could be enough:

  if $covered.policy.each.flat_map(&:counts).detect { _1&.zero? }
    Kernel.exit(1)
  end

A similar behavior is found in simplecov: https://github.com/simplecov-ruby/simplecov/blob/b6c2d4208a5fa395ce09d7e1d3b074f680ee29b0/lib/simplecov.rb#L239

everton avatar Nov 07 '24 10:11 everton