Posts

Showing posts from December, 2012

Dry up your code: Simple OR clause [1st mile]

1. Simple OR clause Consider the following scenario, #1 - Given the "user" launches the app  #2 - When he logs in #3 - Then he sees the home page Lets look at step #2 closer and identify possible variations of it #2.0 - When he logs in                 [Def #1: When /^he logs in$/ ] #2.1 - When "user" logs in           [Def #2: When /^"([^"]*)" logs in$/ ] #2.2 - When "admin" logs in        [Def #2: When /^"([^"]*)" logs in$/ ] #2.3 -  When she logs in              [Def #3: When /^she logs in$/ ] Believe me variation #2.3 will be used a lot if your team has a healthy gender ratio. Now do we need 3 step definitions to capture all the 4 variations. Nope (otherwise why am I writing this blog anyways :-) Step...