How do you "nest" or "group" Test::Unit tests? How do you "nest" or "group" Test::Unit tests? ruby ruby

How do you "nest" or "group" Test::Unit tests?


You can achieve something similar through classes. Probably someone will say this is horrible but it does allow you to separate tests within one file:

class MySuperTest < ActiveSupport::TestCase  test "something general" do    assert true  end  class MyMethodTests < ActiveSupport::TestCase    setup do      @variable = something    end    test "my method" do      assert object.my_method    end  endend


Test::Unit, to my knowledge, does not support test contexts. However, the gem contest adds support for context blocks.


Shoulda https://github.com/thoughtbot/shoulda although it looks like they've now made the context-related code into a separate gem: https://github.com/thoughtbot/shoulda-context