Is it possible to write a rake task that will run a single specified Unit test or a single specified Functional test?

有帮助吗?

解决方案

You can run a particular test method from the test case by using the -n switch with the test method name.

$ ruby -Itest test/unit/post_test.rb -n test_the_truth

Loaded suite unit/post_test
Started
.
Finished in 0.023513 seconds.

1 tests, 1 assertions, 0 failures, 0 errors

http://guides.rubyonrails.org/testing.html

It means your rake task will look like

task :tester => :environment do
  `cd #{Rails.root} && ruby -Itest test/unit/post_test.rb -n test_the_truth`
end
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top