Skip to content

Background may need clarification #103

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

Open
bgusach opened this issue Apr 22, 2025 · 5 comments
Open

Background may need clarification #103

bgusach opened this issue Apr 22, 2025 · 5 comments

Comments

@bgusach
Copy link

bgusach commented Apr 22, 2025

👓 What did you see?

According to the docs:

You can only have one set of Background steps per Feature or Rule

https://cucumber.io/docs/gherkin/reference/#background

It's not clear to me whether:

a) Both feature and rule can have a background
b) Either feature or rule can have a background, but not both.

I think it's (a), but that sentence needs clarification.

✅ What did you expect to see?

Maybe something like this?

A Feature can have only one set of Background steps. The same goes for a Rule. Both a Rule and its Feature may have a Background at the same time.

@luke-hill
Copy link
Contributor

luke-hill commented Apr 23, 2025

There is a historical reason for this. When we introduced Rule, we inadvertently permitted background steps in Rules. However this was semi-contentious at the time, and not universally agreed upon by the TLC.

So in essence, for now, it's a "Yes you can do it, but we don't want to recommend it". That is likely why the docs are a bit vague in this area.

@bgusach
Copy link
Author

bgusach commented Apr 23, 2025

Does that mean that (a) is the right one?

I think it's perfectly fine to say in a reference that something is possible but not recommended—but it must be crystal clear at all costs. In other words, that paragraph could look like this?

It's possible to have a Background in a Feature, a Rule, or even both—however, this is generally discouraged.

@luke-hill luke-hill transferred this issue from cucumber/common Apr 23, 2025
@luke-hill
Copy link
Contributor

I've moved this over to website for discussion. But I think it's something we never got a consensus on. If you want to submit a PR i'll gladly review it

@davidjgoss
Copy link
Contributor

I agree we should document what it does clearly even if we don't like it much. +1 to a PR, the language in your last comment seemed good. I'd also spell out that the background steps from the feature and rule would be concatenated, just to avoid any doubt.

@luke-hill
Copy link
Contributor

To clarify as well @bgusach the answer is (a). Both feature and background can have them. If just 1, use the 1, if both, use feature (background), first followed by rule (background), second

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants