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

前端 未结 10 1858
再見小時候
再見小時候 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:25

    Well, I accomplished basically the same way in a really ugly and horrible fashion, but it was quicker. :) Once I realized that the tests are run alphabetically:

    class MyTests < Test::Unit::TestCase
    def test_AASetup # I have a few tests that start with "A", but I doubt any will start with "Aardvark" or "Aargh!"
        #Run setup code
    end
    
    def MoreTests
    end
    
    def test_ZTeardown
        #Run teardown code
    end
    

    It aint pretty, but it works :)

提交回复
热议问题