I'm using the latest version of Ruby(2.0.0) and Minitest (5.0.8).
I am looking for a way to create 2 methods, a before and an after. The before method should run before Minitest even starts on the testcases and the after should run once ALL of the test have finished.
I already use the setup() and teardown() methods that run before and after each individual test but I'm looking for something that wraps around the whole Minitest suite.
I have seen:
Ruby Minitest: Suite- or Class- level setup?
and
Before/After Suite when using Ruby MiniTest
Which are both out of date with the latest version of Minitest.
Is this still possible?
The before
method is easy, you just configure your test setup to call a method before the Minitest starts.
The after
method can be achieve by using the method Minitest.after_run(&block)
provided by the Minitest API. Ex:
Minitest.after_run do
puts 'All tests finished'
my_method_call()
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With