Grouping Scenarios in .feature Files Using Multiple 'Feature' Keywords
🤔 What's the problem you're trying to solve? I'm looking for a way to implement context(name, config, fn) with the aim of grouping tests according to a name or category.
✨ What's your proposed solution? I've noticed that within the .feature files there is a keyword called "Feature" that allows grouping "Scenarios". The idea would be to use "Feature" multiple times to perform this grouping.
⛏ Have you considered any alternatives or workarounds? I believe that the solution that generates the best impact is to be able to use "Feature" multiple times and that it only serves to group the scenarios that are below.
Feature: description 1
Scenario: description 1
When step of when
Then step of them
Feature: description 2
Scenario: description 2
When step of when
Then step of them
📚 Any additional context?
I have some example images that I will provide in the final Issue post.
This looks like you're using some form of additional plugin / framework (Possibly a cypress preprocessor, I'm not sure).
Feature as a keyword is designed to appear once at the top of each feature file *.feature, to indicate what feature it is you are describing (Possibly testing). It's design is a little more than just grouping scenarios, as other keywords (Such as Rule), can do this behaviour also.
Ideally you would use multiple feature files for multiple features, thus keeping your features separate. If you need to describe nuances of your features, we have a keyword Rule that acts as a wrapper to partition up your Feature
If you would want to suggest changes to the gherkin language, such as this, then the gherkin repo would be best. However advanced warning, something like this is quite a large change, and would need to satisfy a large subsection of the gherkin-using community. Please bear that in mind.
The gherkin repo is here: https://github.com/cucumber/gherkin
I'll leave this open for now to await your reply
Indeed, I'm using Cypress in conjunction with a preprocessor, specifically the cypress-cucumber-preprocessor. I've just made this request in the corresponding repository. However, it would be interesting to delve into how the same result could be achieved using rules. It's also worth noting that this might not be a valid solution for me if the preprocessor has limitations.
I agree with @luke-hill: this looks like a need that can be solved using a plugin.
I have a similar need of making reports which groups several Features into sections (without cypress). I made a plugin wich groups Feature based on their classpath directory and custom annotations in the feature files.
@jasp402
Have you considered the Rule keyword for grouping scenarios ?
NOTE: That would allow you one additional level of grouping below Feature.
SEE ALSO:
- https://docs.cucumber.io/docs/gherkin/reference/ (Section: Rule)
Have you tried using @tagging if you need to selectively run subset of feature file scenarios for example and helps provide meta info to help describe scope of tests.
On Wed, 28 Jun 2023, 20:57 jenisys, @.***> wrote:
@jasp402 https://github.com/jasp402 Have you considered the Rule keyword for grouping scenarios ?
NOTE: That would allow you one additional level of grouping below Feature.
SEE ALSO:
- https://docs.cucumber.io/docs/gherkin/reference/ (Section: Rule)
— Reply to this email directly, view it on GitHub https://github.com/cucumber/common/issues/2151#issuecomment-1612020599, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLFFUEERPBDPANWNSBY7LTXNSEEBANCNFSM6AAAAAAZXKZKZI . You are receiving this because you are subscribed to this thread.Message ID: @.***>