🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🪟 Windows TippsHeader and Footer not showing in Excel(14.09.2026 um 22:43 Uhr)
🕵️ SicherheitslückenBurn Out, Or Fade Away(14.09.2026 um 14:25 Uhr)
🪟 Windows TippsKB5129194 Windows 11 26H1 Out of Band Update - Deskmodder.de(14.09.2026 um 19:25 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🪟 Windows TippsHeader and Footer not showing in Excel(14.09.2026 um 22:43 Uhr)
🕵️ SicherheitslückenBurn Out, Or Fade Away(14.09.2026 um 14:25 Uhr)
🪟 Windows TippsKB5129194 Windows 11 26H1 Out of Band Update - Deskmodder.de(14.09.2026 um 19:25 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 4 Min Lesezeit
0

Solving a problem of duplicate steps in Cucumber BDD testing

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

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




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






video-player.feature




CODE
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 introduced interesting feature called . You should make it more complex, splitting on common steps + pairing pattern steps.


  • 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 .



    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:




    CODE
    └── 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:




    CODE
    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:




    CODE
    └── 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 ❤️

    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
  • Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    1 Quelle
    Mastering Claude and ChatGPT: Developers Guide to Advanced Prompting
    1 Quelle
    Build vs Buy: When to Outsource Machine Learning Development
    1 Quelle
    SchemaCrawler LLM Context: Extract and Prune Relational DB Schemas
    Ä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 ...