-
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
Parameterization for spec-style tests? #80
Comments
We have prototyped |
For what it’s worth, the Ginkgo And the rspec-parameterized constructs seem to be used even less relative to the number of public codebases using rspec. 119 of about 816k (below 0.015%), 100x fewer than Ginkgo’s There is a ton of churn on this topic in the Jasmine and Mocha communities. It seems to be a desired feature, but adding it has been resisted so there hasn't been a clear "winning" implementation. These data points lead me to conclude there isn't a particularly strong prior-art way to do this for the Specification DSL. That should give us some license to steal the best ideas from all of the above, and combine that with our own flavor. I personally prefer some variant of the |
How about: describe("some fixture",
where(
example(1,2,3),
example(2,3,5),
example(3,4,7)
), (a,b,c) -> {
it("adds up the numbers correctly", () -> {
assertThat(a+b, is(c));
});
}); Perhaps we add a synonym of Or perhaps we replace describe("some fixture", (a,b,c) -> {
it("adds up the numbers correctly", () -> {
assertThat(a+b, is(c));
});
}, withExamples(
example(1,2,3),
example(2,3,5),
example(3,4,7))
); If the second of these, then the implementation is ~0 effort ;) |
Just throwing in my $0.02: The first example is quite similar to the closest I've seen in data driven testing support in Jasmine, which I found (and stole from) here: http://blog.jphpsf.com/2012/08/30/drying-up-your-javascript-jasmine-tests I like the second one a little better, though, if only because it's much more similar to how data driven testing is supported in the Cucumber style specs. Not sure if my vote counts for anything, but hey :) |
#58 focuses specifically on parameterization for Gherkin-style tests (
scenarioOutline
). It would be nice to provide a cleaner parameterized test API for Spec-style tests too.There is no obvious consensus among spec-style test runners as to the "canonical" way to do this. RSpec, Jasmine, and Mocha, for example, do not have any special support for parameterization out of the box. There are a few data points from the community, though:
We can use this thread to discuss the best approach for Spectrum, either taking ideas from above or going in a different direction.
The text was updated successfully, but these errors were encountered: