method
add_setup_hook
v1_9_3_125 -
Show latest stable
-
0 notes -
Class: TestCase
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
add_setup_hook(arg=nil, &block)
public
Adds a block of code that will be executed before every TestCase is run. Equivalent to setup, but usable multiple times and without re-opening any classes.
All of the setup hooks will run in order after the setup method, if one is defined.
The argument can be any object that responds to #call or a block. That means that this call,
MiniTest::TestCase.add_setup_hook { puts "foo" }
… is equivalent to:
module MyTestSetup def call puts "foo" end end MiniTest::TestCase.add_setup_hook MyTestSetup
The blocks passed to add_setup_hook take an optional parameter that will be the TestCase instance that is executing the block.