Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize test runs #595

Open
novemberborn opened this issue Mar 3, 2016 · 10 comments
Open

Randomize test runs #595

novemberborn opened this issue Mar 3, 2016 · 10 comments
Labels
💵 Funded on Issuehunt This issue has been funded on Issuehunt enhancement new functionality help wanted scope:scheduling

Comments

@novemberborn
Copy link
Member

novemberborn commented Mar 3, 2016

Issuehunt badges

We should kick off tests in a random order. This will flush out any interdependencies per test. However the order should be reproducible to debug such interdependencies. Ruby's minitest has a --seed option which can be set on the CLI to control the order. A random seed is used if no value is provided and it's reported in the output.

Starting tests in a random order within a test file is the easiest place to start. Presumably .serial would run in source order.

We could consider running test files in a random order as well, though they're already somewhat random because each test file runs in its own process, and because each test file runs in its own process it'd be hard to run them in a deterministic order. So probably best not to even try.

Thoughts?

There is a $80.00 open bounty on this issue. Add more on Issuehunt.

@novemberborn novemberborn added enhancement new functionality question labels Mar 3, 2016
@vadimdemedes
Copy link
Contributor

This will flush out any interdependencies per test.

I believe it is already being done, as we start all tests at the same time and running them in parallel.

In a way, order of running/output is random, because it depends on the execution speed of the test.

@novemberborn
Copy link
Member Author

We kick off the tests in source order though. The asynchronous ones will start to interleave but synchronous tests won't. And synchronous tests will block asynchronous ones that started earlier.

@sindresorhus
Copy link
Member

Yes, we discussed this a while ago and agreed it would be very useful, but not a priority for 1.0.0.

https://github.com/bahmutov/rocha is a good inspiration.

"I thought it was a pretty neat idea. I really like that he saves the execution order when tests fail. That way things stay reproduceable until fixed." - @jamestalmage about the above.

@sindresorhus sindresorhus added this to the Future milestone Mar 3, 2016
@jamestalmage
Copy link
Contributor

One thing that will be difficult about this when it comes to AVA, will be the fact that there's no good way to enforce ordering across multiple processes. That would only cause problems if multiple test files are accessing the same system resource (disk, database, etc). I don't think that is an easy problem to solve, and is probably best just ignored initially. Random ordering per file would provide a lot of value on it's own.

The asynchronous ones will start to interleave but synchronous tests won't.

Agreed. Additionally, most asynchronous tests will currently interleave in a predictable/identical way for each test run. Only async tests with random delays (aka: those that access system resources) will end up interleaving randomly.

@novemberborn
Copy link
Member Author

This is a neat approach to finding which tests in which order cause a failure: http://make.bettermistak.es/2016/03/05/rspecs-bisect/

@vadimdemedes vadimdemedes added the future we'll get back to this eventually label Mar 25, 2016
@novemberborn novemberborn removed this from the Future milestone Aug 13, 2017
@novemberborn novemberborn added scope:scheduling and removed future we'll get back to this eventually labels Aug 20, 2017
@sindresorhus
Copy link
Member

We could consider running test files in a random order as well, though they're already somewhat random because each test file runs in its own process

I think we should still shuffle the glob-resolved array of files just to be sure.

@ORESoftware
Copy link

@novemberborn sounds like you'd have to save the run order to disk for every run

@IssueHuntBot
Copy link

@IssueHunt has funded $80.00 to this issue.


@mighty-phoenix
Copy link

Hey!
Is this issue still up for grabs(Issuehunt bouny)?
Thanks! @wprater @novemberborn

@novemberborn
Copy link
Member Author

@mighty-phoenix it is, though this behavior could be achieved using the sortTestFiles() feature in 4.1.0.

I'd still like to see it within AVA but the implementation has to be pretty good, now that it's possible to built this on top of AVA for most scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💵 Funded on Issuehunt This issue has been funded on Issuehunt enhancement new functionality help wanted scope:scheduling
Projects
None yet
Development

No branches or pull requests

7 participants