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 execution of sibling scopes/resets #4

Closed
mdwhatcott opened this issue Sep 5, 2013 · 8 comments
Closed

Randomize execution of sibling scopes/resets #4

mdwhatcott opened this issue Sep 5, 2013 · 8 comments

Comments

@mdwhatcott
Copy link
Collaborator

This is to drive out temporal couplings between tests. Technically, the setup and teardown methods should be enough to do this but you just never know...

I think this will be a command line option that is enabled by default and can be disabled (which is how some of the unit tests can avoid being broken by this new feature).

@ghost ghost assigned mdwhatcott Sep 5, 2013
@mdwhatcott
Copy link
Collaborator Author

The big question for me is how this might affect existing tests that depend of consistent execution order...

Also problematic is that fact that I can't create new command line flags. So, the only option is to use invalid values for existing ones (like I've done with json reporting).

@mholt
Copy link
Contributor

mholt commented Nov 9, 2013

@mdwhatcott Now that tests run concurrently, I've noticed a sort of pseudo-randomness in test execution. Is this good enough, or do we want to provide random seeds and let the user specify one, etc, etc...?

@mdwhatcott
Copy link
Collaborator Author

It's more about making sure that unit tests run in any order without any effect on the end result. I've been in situations with frameworks that do randomize execution and have uncovered subtle bugs that hide when you only see the tests executed in deterministic order. The purist in me says we have to have this right now ("How dare we call this a robust testing framework without it!?"). The pragmatist says wait until we get burned by not having it (and I'm still hung up about the command line flag hack that will be required--see my last comment).

@mdwhatcott
Copy link
Collaborator Author

This issue is somewhat related to #70. If we can resolve that issue successfully we could rely on go test running the specs concurrently to root out any issues with the tests that would be masked by synchronous, deterministic execution.

@mdwhatcott
Copy link
Collaborator Author

Not quite sure how to go about this yet so we are deferring this issue. It will be referenced on the wiki for future discussion.

@riannucci
Copy link
Collaborator

Out of curiosity, would it be enough to:

  • for every suite of N !complete Convey blocks
    • for each Convey in the suite
      • if expectChildRun is true
        • with 1/N probability execute the suite

It gets a bit tricky to do with the way that it's doing greedy suite execution right now (e.g. it will execute the first !complete Convey in every suite if expectChildRun is true). If we did this randomized execution, there'd have to be more passes through the test in order to do breadth-first evaluation of Conveys.. since every suite can also have initialization side effects, this would mean that we'd have to restart execution from the top-most suite every time we encountered a new suite that we hadn't seen before.

@mdwhatcott
Copy link
Collaborator Author

Having just rewritten most of the convey package you probably have a much better feel for how this could work at this point. :)

The tests would certainly have to be re-thought--they count on deterministic execution order pretty heavily. Maybe there could be a setting that enables random execution? (sigh...)

I'd be interested to try it out though.

@mdwhatcott mdwhatcott reopened this Nov 10, 2014
@riannucci
Copy link
Collaborator

Probably will need options like -randomize-test-order (bool) and -random-seed (int). The tests for the random execution would probably set the seed at the top of the test (like they do for some other global stuff in prepare()). I would probably have each Convey(..., t, ...) create a new random generator starting at seed so that t.Parallel() doesn't goof things up :).

edited because github thought I had a weird html tag in there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants