Marnen Laibow-Koser wrote:
Piero Di Bello wrote:
How can I have the tests for my Rails app to be executed in a random
At least with RSpec, specs are executed in unpredictable order. I think
it’s the same each time, but it’s not the order in which they appear in
the spec file.
But why do you need this anyway? Each test should start from a clean
slate, so the order should be completely immaterial.
First I’ll say I completely agree with this. If tests/specs fail or pass
depending on the order of execution then there must be serious problems
with your test suite.
Now to address the OP. I know of nothing “built-in” any of the testing
frameworks for this. What I suppose you would need to do is write your
own script that searches though your project for all test classes then
executes them in a random order.
This, however, would only randomize the testing classes, each test
within each class would still execute in whatever order the test
framework decided to run them. Which, would mean that you would probably
also have to replace the test runner with your own that could randomize
each method of each test class.
In conclusion if this is a solid requirement of your project, I’m really
glad it’s your project and not mine.