I have a bunch of RSpec Rake tasks defined that I'd like to run in a specific order when I run the entire suite of tests.
I've tried something like this:
task :run_in_order => [:one, :two, :three] do
puts "Run suite of tests"
end
And it runs the first test and then stops and doesn't run the rest of the tasks.
So if using Rake syntax it doesn't work. Is there a way to note task dependencies for RSpec Rake tasks?
Check this http://blog.davidchelimsky.net/2012/01/04/rspec-28-is-released/
–order rand We added an --order option with two supported values: rand and default.
rspec --order random (or rand) tells RSpec to run the groups in a random order, and then run the examples within each group in random order. We implemented it this way (rather than complete randomization of every example) because we don’t want to re-run expensive before(:all) hooks. A fair tradeoff, as the resulting randomization is just as effective at exposing order-dependency bugs.
When you use --order random, RSpec prints out the random number it used to seed the randomizer. When you think you’ve found an order-dependency bug, you can pass the seed along and the order will remain consistent:
--order rand:3455 --order default tells RSpec to load groups and examples as they are declared in each file
Basically you should order your tests in a spec file an then execute it with --order default
option.
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With