2017-06-29 118 views
1

例如,在Jasmine,你可以這樣做:Minitest如何嵌套測試?

describe('Person', function() { 
    describe('movement methods', function() { 
    it('#run', function() { 

    }); 
    it('#jump', function() { 

    }); 
    }); 
}); 

隨着MINITEST,似乎你不能有一個「運動方式」的範疇。你必須這樣做:

class PersonTest 
    def test_run 
    end 

    def test_jump 
    end 
end 

有沒有辦法在Minitest嵌套?

回答

2

是的,你可以。你可以做這樣的事情(不是最漂亮的):

class Person < ActiveSupport::TestCase 
    class MovementMethods < ActiveSupport::TestCase 
    test "#run" do 
     # something 
    end 

    test "#jump" do 
     # something 
    end 
    end 
end 

還要考慮使用minitest/spec,你可以寫你的測試情況下,更具有可比性茉莉花片段:

require 'minitest/spec' 

describe Person do 
    describe 'movement methods' do 
    it '#run' do 
     # something 
    end 

    it '#jump' do 
     # something 
    end 
    end 
end