.agents/skills/e2e-cucumber-playwright/references/cucumber-best-practices.md
Use this reference when writing or reviewing Gherkin scenarios, step definitions, parameter expressions, and step reuse in Dify's e2e/ suite.
Official sources:
Cucumber scenarios should describe examples of behavior, not test implementation recipes.
Apply it like this:
A scenario should usually prove one workflow or business outcome. If a scenario wanders across several unrelated behaviors, split it.
In Dify's suite, this means:
Good reuse reduces duplication. Bad reuse hides meaning.
Prefer reuse when:
Write a new step when:
Use Cucumber Expressions for parameters unless regex is clearly necessary.
Common examples:
{string} for labels, names, and visible text{int} for counts{float} for decimal values{word} only when the value is truly a single tokenKeep expressions readable. If a step needs complicated parsing logic, first ask whether the scenario wording should be simpler.
Step definitions are glue between Gherkin and automation, not a second abstraction language.
For Dify:
this as DifyWorldasync functionDifyWorld and existing support code for shared contextTags should communicate run scope or session semantics, not become ad hoc metadata.
In Dify's current suite:
@unauthenticated changes session behavior@authenticated is descriptive/selective, not a behavior switch by itself@fresh belongs to reset/full-install flows onlyIf a proposed tag implies behavior, verify that hooks or runner configuration actually implement it.