cucumber - Should Gherkin scenario always have When step? -


when defining scenarios in gherkin there no clear distinction between given , when steps, i.e. there no active interaction system user , purpose of validation verify how system should under circumstances.

consider following:

scenario: show current balance given user on account page user should see balance 

vs

scenario: show current balance when user goes account page user should see balance 

i not sure use second variant. if have multiple scenarios sharing context "user on account page" , of them have additional user actions while others don't, seems me should valid keep "user in account page" given step though may lack "when" scenarios. valid approach?

formally , technically cucumber/specflow doesn't require write when-step or rather given/when/then's executed in order written in scenario. in regard don't need when-step.

but, andy waite wrote about, when-step shows on action or event system takes "setup" new state verifies in then-step. in regard when-step should present in every test (as wrote: testing otherwise).

that leaves final comment; verifying setup (given system started, database clean naïve example). in such scenarios when-step skipped.

so, always, comes down readability , understanding. scenarios written make our thoughts systems behavior concrete , clear. use form optimize understanding , learning behavior in question.

without thinking hard on guess general advice use when-step makes event or behavior apparent , clear. shy away implicit , hidden behavior when possible.

i hope helps.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -