Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Rails 5 order test cases randomly?

It's mentioned in the upgrade guide Rails 5 will order tests randomly. It's trivial to revert to fixed order, but I'm just wondering why this change was made? Is it to support parallel testing?

like image 228
mahemoff Avatar asked Dec 20 '22 07:12

mahemoff


2 Answers

Random test ordering is good practice. If you always do your test in a fixed order there is a chance your tests depend on each other. Each test should have no side effects, and random ordering guarantees this.

like image 80
ptd Avatar answered Dec 30 '22 12:12

ptd


Refereed to Rails 5 Awesome features

Rails 5 order test cases randomly, the new runner is, in fact, my favourite piece of Rails 5. I love minitest, and I always was a bit envy of RSpec users, as they have a great runner that allows you to specify the file and line number of a failing spec.

Now, thanks to Yves Senn, we have the same feature when using Rails’ minitest.

like image 21
Sumit Munot Avatar answered Dec 30 '22 12:12

Sumit Munot