How to run code before each test case in all tests in MiniTest?

I need to run the code before each test in all my tests in MiniTest.

Before that, I:

MiniTest::Unit::TestCase.add_setup_hook do ...code to run before each test end 

After updating MiniTest to version 4.7.2, it shows the following error:

 undefined method `add_setup_hook' for MiniTest::Unit::TestCase:Class (NoMethodError) 

I am using Ruby MRI 2.0.0p0.

Decision

 module MyMinitestPlugin def before_setup super # ...code to run before all test cases end def after_teardown # ... code to run after all test cases super end end class MiniTest::Unit::TestCase include MyMinitestPlugin end 
+6
source share
2 answers

I think you are looking for the setup() method.

+2
source

All Articles