我需要为某些类或系统范围的 Rails 测试设置和拆卸方法,但我只找到了一种方法来定义适用于每个测试级别的常规安装/拆卸方法。
例如:
class ActiveSupport::TestCase
setup do
puts "Setting up"
end
teardown do
puts "tearing down"
end
end
将为每个测试用例执行输出,但我想要类似的东西:
class ActiveSupport::TestCase
setup_fixture do
puts "Setting up"
end
teardown_fixture do
puts "tearing down"
end
end
它将在所有测试方法之前_
执行设置夹具,然后在所有测试方法之后执行拆卸夹具。_
有没有这样的机制?如果没有,是否有一种简单的方法来修补这个机制?