在这里,你可以定义它 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
Run Code Online (Sandbox Code Playgroud)
跑: rake test:randomize:all
请记住,文件测试中仍将按照它们出现的顺序执行.我想你可以通过猴子补丁测试单元来实现这一点.
您可能希望查看“ZenTest 3.9.0:现在有更多邪恶”(无法做直接链接,使用谷歌的缓存)
Added ability to set test execution order, defaults to :random. EVIL!
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1254 次 |
| 最近记录: |