rubysimplecov

Skip simplecov summary when there are test failures


I have a requirement, Simplecov should print this line

Coverage report generated ...

only if the test suite is green.

Is this possible?

Here's my initializer

SimpleCov.start do
  add_filter "/test/"
  coverage_dir "/tmp/coverage/"
end

Solution

  • There is a at_exit hook in SimpleCov where you can skip the message

    SimpleCov.at_exit do
      SimpleCov.result.format! if all_test_passed
    end
    

    but could not find a workaround for 'all_test_passed'. Did not find a way to get summary so that i can check if all tests passed.