-
Notifications
You must be signed in to change notification settings - Fork 73
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
Suggestion: Multi-dimensional scenario outlines #219
Comments
That's an interesting idea I'd never thought of. I think it would be relatively easy to change the feature parser to support multiple example tables then generate the scenarios accordingly. The feature parser is pluggable so you could give it a try if you felt inclined. I'm not sure I'd go down this route though as I don't think the specification would really add any clarity / value. Instead what about generating the test in code? After the spec is parsed it's just an array of strings, which would be far easier to generate with a set of nested for loops and a template. var scenarios = []
['zebra', 'fox', 'eagle'].forEach((animal) => {
['talk to', 'befriend'].forEach((action) => {
[{ result: 'nothing much', feeling: 'nonplussed' }, { result: 'something amazing', feeling: 'over the moon' }].forEach((consequence) => {
var title = `${animal} ${action} ${consequence.result} ${consequence.feeling}`
var steps = render(template, { animal: animal, action: action, consequence: consequence }).split('\n')
scenarios.push({ title: title, steps: steps })
})
})
}) template
|
This is super helpful, thank you! I'm going to start out with the code-generated tests, and maybe also generate a feature file for non-developers to read (but not edit obviously). If I end up looking at the parser I'll let you know! |
OK to close? |
Yep, thanks again. |
@willclarktech Any luck implementing this? I believe this should be available out of the box. Creating a single |
@cressie176 Please reopen. This should at least be available as one of |
In support of @willclarktech's feature requst, please compare these two sets of examples. Proposed:
Currently available equivalent:
|
@lolmaus I didn't end up pursuing this as a colleague convinced me that end-to-end tests should focus on scenarios which efficiently provide confidence in your application, rather than aiming to be exhaustive. I did end up writing this library to help with writing exhaustive (e.g. unit) tests with Yadda/Gherkin-like steps in Mocha: https://github.com/LiskHQ/mocha-bdd. It supports nesting rather than multi-dimensional templates per se but that's more easily generalisable. It's obviously not as human-readable as Yadda feature files, but I'm now doubtful whether Yadda-style feature files should even cater for anything approaching exhaustive test suites. |
Re-opening for the purpose of discussion. On review I'm not keen to implement multiple example tables as described above - as mentioned above I think they fail from a readability perspective. What might be worth considering is extending the example syntax to support a named data feed, e.g.
The feed could be an array of arrays or function that yields an array of arrays, that Yadda would use for examples
Creating the array / implementing the function would be the responsibility of the program using Yadda, rather than Yadda itself. Then you could generate data in any which way you wanted. |
I have a really long, multi-step form, which gets validated at various points along the way, and certain answers can block submission. I'd like to end-to-end test that the various permissible routes through the form all allow the form to be submitted at the end. (In almost all cases the validity of a field's value is independent of the values of other fields.)
I believe my current options are:
Ideally I'd be able to define a set of example values for each of several fields, and a separate scenario would run for each combination.
For example with something like this in a feature file (I have no opinions about syntax btw):
yadda would run 3 x 2 x 2 = 12 scenarios.
The text was updated successfully, but these errors were encountered: