Scenarios should be grouped by feature
Feature should be translated to describe and Scenario to test.
Currently, each Scenario is wrapped in separate describe. Don't know exactly what was initial intent, but what you are asking seems doable.
Except: as of gherkin 6 there is a new concept: Rule which brings one more layer of depth.
While it seems doable, what benefit would it have? In the final output, each scenario should be a test, everything outside that is open for change.
One more case, would be, that there always is only one Feature, can there even be two Features in one Scenario?
Pros:
- It will have more descriptive name in case of test failures and/or issues, currently it is
feature Scenario name Scenario name(so you see thatScenario nameis repeated). - You will need to translate background to
setuponly once, as setups are shared among all tests indescribe. - You cannot have multiple
FeatureinScenario, but you can have multipleFeaturein single file and multipleScenariosin singleFeature.
- Naming can and should be fixed regardless of
describeandtesthierarchy. - it can be done in global scope as well.
describeisn't a requirement for that. - If that (one can have multiple
Featuresin single*.featurefile) is true, it is odd. Even then have them wrapped around indescribeisn't a requirement.
Currently, it seems for me it there are 2 possible ways regarding describe
- it won't be used at all
- it will wrap each test (
scenario).
Dunno. In either case, it isn't neither a primary concern, nor one that somehow drastically would change how lib interacts with end user (developer).
@revati if you have multiple Feature within single file, and then you implement setup for Background then these two will collide as both setups will run. Alternative is that describe would be used for each Rule and we would disallow multiple Features per file.
I'm more inclined towards seconds option, as it would provide better integration with Rule and disallow multiple Features in single file.
Is it possible to create some sort of poll in github? 😅
No other way than "emoji voting".
Cucumber doesn't even support multiple features in a single file: https://stackoverflow.com/questions/30599752/multiple-feature-inside-single-feature-file
I don't think that should be something to worry about. Either the things in the single file being tested are so closely related that they are part of the same feature, or they are separate enough that they deserve their own feature files. This seems to be the philosophy they are following.