All threads / Running only a part of a huge (2000+) specs suite
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Running only a part of a huge (2000+) specs suite

makaroni4 asked in Testing

I'm working on a Rails app with 2000+ feature specs. That's a lot and takes 45+ min to run (8min when running in parallel containers).

What are the strategies to speed this up? Is there a smart way to partially run a spec suite? (for example, run only checkout flow specs if one of checkout flow controllers/models/views were changed)

You can tag specs, say for specs related to checkout flow, you can tag them as "checkout" like this :

# specs/discount_checkout_spec.rb
it "should checkout with discount", :checkout do
    # some test code here
end

then you can specify rspec to only run tests are tagged with :checkout like this : rspec spec --tag checkout

In addition to what Axel wrote earlier, you could also add a focus-tag to specific cases, should you only want to test them individually. It works like so:

# specs/discount_checkout_spec.rb
it "should checkout with discount", focus: true  do
    # some test code here
end
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 62,791+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.