Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add additional test tasks in Rails 5

In rails 4.x you used to be able to easily add additional Rails::TestTasks that would run alongside the core Rails app tests during rake test. For instance, like this:

http://blog.bigbinary.com/2014/04/26/adding-directory-to-rake-test.html

In Rails 5, none of the approaches I've seen seem to work, and while it seems to be documented/understood around the internet that they no longer work, I haven't seen any mention of the new way to do things.

Anybody know?

like image 859
honktronic Avatar asked Oct 15 '25 04:10

honktronic


1 Answers

It still works but changed in Rails 5.1.3.
Basically rails test runner now picks up everything matching test/**/*_test.rb except files matching test/system/**/*_test.rb so you may not have to do anything if your tests are already within test folder.

You can still setup specific test task under test/ like this:

namespace :test do
  %w[queries reporters services workers].each do |name|
    task name => 'test:prepare' do
      $LOAD_PATH << 'test'
      Rails::TestUnit::Runner.rake_run(["test/#{name}"])
    end
  end
end
like image 162
Alex Dunae Avatar answered Oct 17 '25 18:10

Alex Dunae



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!