Bulwersator
Bulwersator

Reputation: 1132

How can I check within program whatever tests (written using MiniTest gem) are passing?

I want to end with something like

Tests = run_tests()
if !Tests.passed
   puts Tests.errors
   exit
end

start_function_running_for_a_long_time_using_now_verified_code()

Upvotes: 0

Views: 101

Answers (1)

Wally Altman
Wally Altman

Reputation: 3545

Assuming your tests can be run from my_tests.rb, you could run them with a system call and use the exit status to determine if they passed:

`ruby my_tests.rb`

unless $?.success?
  abort "Tests didn't pass; aborting"
end

start_function_running_for_a_long_time_using_now_verified_code()

While it doesn't conditionally print the errors, it does stop execution if the tests failed.

Upvotes: 2

Related Questions