Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Solving a problem of duplicate steps in Cucumber BDD testing

Hello 👋 I'm a maintainer of BDD testing tool. One of the popular requests I'm getting from consumers - to allow duplicate step definitions bound to different features. For example, I need to test an application that has "game" and "v…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Hello 👋



I'm a maintainer of BDD testing tool. One of the popular requests I'm getting from consumers - to allow duplicate step definitions bound to different features. For example, I need to test an application that has "game" and "video-player" pages. Both pages have PLAY button in the interface. I write two scenarios:



game.feature




Given I have not started a game yet
When I click the PLAY button # <- duplicated step
Then the game begins






video-player.feature




Given I am watching a youtube video
When I click the PLAY button # <- duplicated step
Then the video plays






Step implementation for I click the PLAY button is different for each feature.



Official Cucumber docs says it's an anti-pattern and step definitions should be globally unique. Proposed workaround is to modify step pattern to avoid the ambiguity. E.g.:




When('I click the PLAY button in game', ...);
When('I click the PLAY button in video player', ...);






That's annoying!






Existing solutions



Non of official Cucumber implementations supports duplicate steps. They report ambiguous step error once your step matches more than one step definition.



Cucumber plugin for Cypress introduced interesting feature called Paring. It allows to have duplicate step definitions paired to particular features via special configuration pattern. For example, having a files structure:




└── features/
├── steps/
│ ├── common.ts
│ ├── game.ts
│ └── video-player.ts
├── game.feature
└── video-player.feature






I can configure step paths with special keyword [filepath]:




stepDefinitions: [
'features/steps/common.ts',
'features/steps/[filepath].ts', // <- pair steps to particular feature
]






During steps loading, [filepath] will be replaced with actual feature name and these steps will be paired to the feature. Now it is possible to have separate steps I click the PLAY button for "page" and "video-player".






Drawbacks



Although I like that pairing technique, I see two drawbacks:




  1. You can't just define steps as a single string pattern, see a common mistake. You should make it more complex, splitting on common steps + pairing pattern steps.


  2. Pairing can't be resolved without reading the configuration. That is mostly for tools like IDE extensions, for navigating to step definition by cmd + click. Currently, the most popular one does not support it, but hopefully will.







Proposed solution



While thinking about steps pairing in Cypress plugin, I've got another idea how it can be implemented. The solution is inspired by Next.js route groups.



We can introduce steps scope - a file or directory with name in parenthesis, e.g. (game) or (video-player).



Step definitions inside scoped directory are applicable only to features inside that directory.



This is the only rule one should know to understand the approach.



Now we can define the file structure:




└── features/
├── steps/
│ └── common.ts
├── (game)/
│ ├── game.feature
│ └── steps.ts
└── (video-player)/
├── video-player.feature
└── steps.ts








  • (game)/steps.ts are applied only to game.feature


  • (video-player)/steps.ts are applied only to video-player.feature


  • steps/common.ts are applied to both



The main advantage is that any tool or human can understand paring without reading configuration.

The configuration itself simply defines steps glob without any patterns:




stepDefinitions: 'features/**/*.ts'






Some projects have separate directories for features and steps. For such cases, the rule can be slightly enhanced:



Scoped step definitions are applicable only to features having that scope in the path.



Now the following structure is also possible:




└── features/
├── steps/
│ ├── common.ts
│ ├── (game).ts
│ └── (video-player).ts
├── (game).feature
└── (video-player).feature







  • steps from steps/(game).ts will be applied only to (game).feature, because feature path contains (game)

  • steps from steps/(video-player).ts will be applied only to (video-player).feature, because feature path contains (video-player)

  • steps from steps/common.ts will be applied to both features, because there are no scoped directories in steps path



Such file structure explicitly shows how features are connected to steps.






Conclusion



I think, scoped duplicate steps are reasonable, especially for testing large applications. I haven't seen file-based solutions before and would appreciate any feedback from you. All of you have different projects with unique structure. Feel free to share, how that solution matches your setup.

Thanks in advance and happy testing ❤️

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Solving a problem of duplicate steps in Cucumber BDD testing

Thematisch verwandte Begriffe: Solving, problem, duplicate, steps · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94097 | A vulnerability was determined in Netcore NBR200V2 1.3.241127.071246. Th…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick