As a typical Gherkin test has many parts, only executing parts of it may result in needed parts not being executed which will result in an otherwise successful test failing. Here are some examples:
If a background is used which sets up state and a scenario is marked as .only. Then the background will not be executed. This will result in hard to diagnose test failures.
If a given is used to setup state and but one of the when/thens is marked as .only then they will likely fail as the given wasn't run.
In general its best to apply .only at the feature level to ensure consistency. However as it can be applied at various levels, the recommendation is to warn developers of the issue if they attempt to do it.
54 Address the first point. Now when a scenario is marked as .only it will always execute the background if one is present. This does not resolve the issue for G/W/T however.
For scenarios, .only doesn't make sense as running a single step is likely not useful. As such the current recommendation is to throw an exception when trying to use .only on a step.
As a typical Gherkin test has many parts, only executing parts of it may result in needed parts not being executed which will result in an otherwise successful test failing. Here are some examples:
In general its best to apply .only at the feature level to ensure consistency. However as it can be applied at various levels, the recommendation is to warn developers of the issue if they attempt to do it.