Ruby on rails 如何使用Minitest进行嵌套测试?

Ruby on rails 如何使用Minitest进行嵌套测试?,ruby-on-rails,minitest,Ruby On Rails,Minitest,例如,在中,可以执行以下操作: describe('Person', function () { describe('movement methods', function () { it('#run', function () { }); it('#jump', function () { }); }); }); 在Minitest中,似乎不能有“移动方法”类别。您只需执行以下操作: class PersonTest def test_run

例如,在中,可以执行以下操作:

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中嵌套吗?

是的,你可以。你可以这样做(不是最漂亮的):

注意:
MovementMethods
将充当并行测试用例,而不是嵌套测试用例。这意味着;对于
MovementMethods
内部的任何测试,将永远不会执行
setup
inside
Person
class Person < ActiveSupport::TestCase
  class MovementMethods < ActiveSupport::TestCase
    test "#run" do
      # something
    end

    test "#jump" do
      # something
    end
  end
end
require 'minitest/spec'

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

    it '#jump' do
      # something
    end
  end
end