-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support running tests in a random order? #47
Comments
I'm glad Spectrum has been helpful for you, @tjarratt . Thanks for the feedback, it helps motivate us to keep working on it. Spectrum doesn't currently support randomization, you're right about that. I'm definitely open to the idea, though. A PR would be great if you get the time and are interested in seeing this through. In general, our approach has been to follow the example of RSpec and Jasmine, so we'd want Spectrum to behave in a similar way. I often use their examples and even test cases to match behavior. It looks like both RSpec and Jasmine use CLI flags and config files to activate randomization. How would you propose activating/configuring the random ordering (and seed)? Spectrum currently doesn't have any kind of project-wide config or CLI interface. I imagine you could do it file-by-file with an annotation parameter like |
Sorry to took me two weeks to get back to this idea, I'm still quite interested in getting a PR together. As a very-infrequent contributor to Jasmine, it warms my heart to hear that other people in the BDD community look to it's test cases for matching behavior. That is literally awesome. Thank you. I think you're absolutely right on a few points here
So my proposal is to introduce two specific system properties:
.. and that both the order of the suites, and the order of the specs within a given suite should be randomized. I'll have to look into jasmine/rspec, but I don't think either of those randomize the order of specs across separate suites. Peeking into the code it seems like introducing a At the risk of asking too many inane questions, is it worth considering breaking out a separate package for this? The current size of the |
Sounds like you've got some great ideas. A few thoughts:
|
#51 contains a SpectrumOptions annotation and there is the start of a method to use system properties as a fallback when options are not provided. |
@ashleyfrieze thanks for the info! I generally try not to couple pull requests, since that can make it harder for maintainers and contributors. If your PR finishes up first I'm more than happy to rebase my changes on yours. At the very least, I can plan ahead to use something like |
@greghaskins the thought of making randomization opt-in makes me a little sad, since I can imagine that few people would think to turn that on, and may never find out their tests are spuriously passing because of test pollution until it's too late. It's especially strange, because the jasmine source implies that random sorting should be the default case. However, I'm not fanatical, and I'm happy to talk about changing that behavior after a release, when it may be reasonable to make breaking changes. |
I hear ya, and I do agree overall. Just trying to balance existing users and expectations from the RSpec/Jasmine world. I'd be open to flipping the default for |
Oh, and I think a system property is sufficient for a first pass at configuration. It's likely something people will turn on in their build script and forget about. And we really want to encourage people to go all-in for randomization instead of case-by-case. |
@tjarratt please review #60 which is where the introduction of |
@tjarratt the |
A basic implementation of this, which is not yet tested/ready is here - ashleyfrieze@301e277 Early feedback appreciated. See the Readme first. |
This looks awesome! Thanks for putting in the hard work, @ashleyfrieze. I had high hopes to contribute here, but my initial efforts fizzled out late last year. Really looking forward to trying this out soon 😄 |
It will be down to @greghaskins on the DSL side of this. It doesn't quite work the way that was discussed higher-up the thread. In other words, there's no defaults to random order thing. It's just an option you can take if you wish. Note also the ability to make the random order repeatable to diagnose failures. I think that's probably a wise idea. Not sure how well it would work in practice. Note also the fact that randomisation is within the hierarchy, not across it. So randomisation happens inside a parent, not across every leaf node. I took this one on to see how the test runner would react to tests executing in a different order than they are discovered. In IntelliJ it seems fine. |
Hey friends!
I rather like this project a lot -- it makes it very easy to write BDD style tests in Java. Many thanks for writing and maintaining it.
I care very deeply about test ordering and randomization - rspec, jasmine, cedar, quick, etc all support test randomization as a way of detecting test pollution.
Is this a feature that is already in Spectrum? I couldn't find any documentation or code to that provided any hint as to how to do this, so I have to assume it doesn't work.
Would this be a desired feature, if I possibly found the time to contribute a PR? Any thoughts as to how it might work?
Thank you!
The text was updated successfully, but these errors were encountered: