Using the built-in Ruby Minitest framework, is there a way to run some code once before the entire suite runs, or even once before an entire TestClass runs? I see in the answer to this question that Test::Unit::after_tests can be used to run code after all tests have been run; is there a similar method to run code before all tests have run?
I would like to use this functionality to initialize a test database before the tests run and tear it down after they have all run.
Thanks!
This is modified from the MiniTest docs (under Customizable Test Runner Types).
Note that you I included
gem 'minitest'to use the gem instead of the bundled version which didn’t have theMiniTest::Unit.runnermethod. Here’s the output.So it calls
#setuptwice, but.before_suiteand.after_suiteonly once, which is what you are looking for I think.