Hardik
Hardik

Reputation: 3895

How to Define order of testcase files execution in Rspec?

Is there a way in Rspec by which I can specify the order of exection by giving file input?

I have a .txt file which contain list of files in ordered manner. I want Rspec to execute testing of files in order specified in .txt file. I am using CAPYBARA with Rspec (USING_CAPYBARA=true rspec -r turnip/rspec -r turnip/capybara spec/features/../../.)

EDIT:

Whenever the features fails on my CI tool, I get the list of file names in sequence which was executed by my CI tool. When I simply run my failing test it works fine, but to debug such issue I need to run the test files in same sequence as the CI tool. So I think if Rspec doesn't provide a way to rerun the specs files in specific sequence I guess I need to write some script for it then

Upvotes: 1

Views: 1126

Answers (1)

spickermann
spickermann

Reputation: 106882

RSpec tells you which seed it used to randomize the order. Look for something like:

Randomized with seed 47311.

You can use that number to re-run specs in the same order:

$ spec spec --seed 47311 # or --order rand:47311

From the documentation: Use the --order option to tell RSpec how to order the files, groups, and examples. The available ordering schemes are defined and rand.

Upvotes: 5

Related Questions