In Ruby's Test::Unit::TestCase, how do I override the initialize method?

前端 未结 10 1859
再見小時候
再見小時候 2020-12-07 14:54

I\'m struggling with Test::Unit. When I think of unit tests, I think of one simple test per file. But in Ruby\'s framework, I must instead write:

class M         


        
10条回答
  •  余生分开走
    2020-12-07 15:27

    FINALLY, test-unit has this implemented! Woot! If you are using v 2.5.2 or later, you can just use this:

    Test::Unit.at_start do
      # initialization stuff here
    end
    

    This will run once when you start your tests off. There are also callbacks which run at the beginning of each test case (startup), in addition to the ones that run before every test (setup).

    http://test-unit.rubyforge.org/test-unit/en/Test/Unit.html#at_start-class_method

提交回复
热议问题