Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Before/After Suite when using Ruby MiniTest

Is there an alternative to RSpec's before(:suite) and after(:suite) in MiniTest?

I suspect that a custom test runner is in order, however I cannot imagine it is not a common requirement, so somebody has probably implemented in. :-)

like image 664
Nickolay Kolev Avatar asked May 04 '11 09:05

Nickolay Kolev


2 Answers

There are setup() and teardown() methods available. The documentation also lists before() and after() as being available.

Edit: Are you looking to run something before each test or before or after the whole suite is finished?

like image 135
Caley Woods Avatar answered Sep 28 '22 07:09

Caley Woods


As noted above in Caley's answer and comments, MiniTest::Unit contains the function after_tests. There is no before_tests or equivalent, but any code in your minitest_helper.rb file should be run before the test suite, so that will do the office of such a function.

Caveat: Still relatively new at Ruby, and very new at Minitest, so if I'm wrong, please correct me! :-)

like image 42
Gert Sønderby Avatar answered Sep 28 '22 07:09

Gert Sønderby