A setup method prepares shared state before each test method runs. In MiniTest, the method name setup is recognized automatically, so every test receives an independently initialized fixture. section 15.5.1
A fresh deck for every test
A CardTest setup method assigns a new PlayingCards::Deck to @deck. test_deal_one can remove one card and expect 51 remaining; test_deal_many can remove five and expect 47, without either test inheriting the other’s mutations. section 15.5.1
The same pattern can be implemented with callbacks: MicroTest observes subclass method definitions, creates an instance for methods beginning with test, runs setup when present, and then invokes the test. section 15.5.2
A setup method supports a predictable test lifecycle:
- Construct the fixture before each test method. section 15.5.1
- Keep tests independent by preventing state changes from carrying between runs. section 15.5.1
- Leave setup optional when a test needs no shared preparation. section 15.5.2

