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

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

    To solve this problem I used the setup construct, with only one test method followed. This one testmethod is calling all other tests.

    For instance

    class TC_001 << Test::Unit::TestCase
      def setup
        # do stuff once
      end
    
      def testSuite
        falseArguments()
        arguments()
      end
    
      def falseArguments
        # do stuff
      end
    
      def arguments
        # do stuff
      end
    end
    

提交回复
热议问题