解决方法@H_404_5@
在这里,你可以在lib / tasks / tasks.rb中定义它
namespace :test do
namespace :randomize do
desc "Randomize tests"
Rake::TestTask.new(:all => "db:test:prepare") do |t|
t.libs << "test"
t.test_files = Rake::FileList[
'test/unit/**/*_test.rb','test/functional/**/*_test.rb','test/integration/**/*_test.rb'
].shuffle
t.verbose = true
end
end
end
运行:rake test:randomize:all
请记住,文件测试中仍将按照它们出现的顺序执行.我想你可以通过猴子补丁测试单元来实现这一点.
namespace :test do namespace :randomize do desc "Randomize tests" Rake::TestTask.new(:all => "db:test:prepare") do |t| t.libs << "test" t.test_files = Rake::FileList[ 'test/unit/**/*_test.rb','test/functional/**/*_test.rb','test/integration/**/*_test.rb' ].shuffle t.verbose = true end end end
运行:rake test:randomize:all
请记住,文件测试中仍将按照它们出现的顺序执行.我想你可以通过猴子补丁测试单元来实现这一点.