Before/After Suite when using Ruby MiniTest

前端 未结 8 1044
时光说笑
时光说笑 2020-12-09 07:30

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

相关标签:
8条回答
  • 2020-12-09 08:07

    You can also add an after test callback by updating your test_helper.rb (or spec_helper.rb) like this

    # test_helper.rb
    
    class MyTest < Minitest::Unit
      after_tests do
        # ... after test code
      end
    end
    
    0 讨论(0)
  • 2020-12-09 08:21

    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! :-)

    0 讨论(0)
提交回复
热议问题