A practical guide to writing When steps in Behavior-Driven Development (BDD) for R Shiny applications. Covers how to model user behavior without leaking UI implementation details, using a driver pattern (R6 class extending shinytest2::AppDriver) as a translation layer between domain-level step names and actual UI mechanics. Explains naming conventions (domain language over UI language), the context pipeline pattern, parameterized steps, multi-step flows, and signs that a When step is too complex. Includes code examples showing how to keep specifications stable across UI refactors.

12m read timeFrom r-bloggers.com
Post cover image
Table of contents
The Purpose of WhenStarting the AppImplementing When StepsNaming When StepsMulti-Step FlowsTesting Error PathsParameterising When StepsSigns a When Step Is Too ComplexThe Pattern in PracticeWrapping up
231 Impressions