【发布时间】:2010-10-31 19:33:40
【问题描述】:
我需要为某些类或系统范围的 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
它将执行 setup_fixture before所有测试方法,然后执行 teardown_fixture after所有测试方法。
有没有这样的机制?如果没有,有没有一种简单的方法可以修改这个机制?
【问题讨论】:
标签: ruby-on-rails ruby activesupport