I'm currently part of a team that is trying to reinforce BDD in our tests and automation. Our tests up to this point were procedural and we want to move towards behavioural steps. An example of our procedural test is printed below
Given I am a registered customer And A browser has been opened When I login And I open the settings dropdown And I go to my preferences page And I set email notifications to true Then Email notifications in the db should be on
The above is purely procedural, and if I’m not mistaken, what we should be moving away from. In my opinion, a more behavioural test would be something like
Given I am a registered customer When I enable email notifications Then Email notifications in the db should be on
Much easier to read and cuts out the procedural steps that we don’t care about. The problems lay in step definitions though. In the first example, the step definitions are simple, one action needed and most importantly, the step before each step sets up the step in question (e.g. setting the notifications to true is no problem because the previous step brought us to the My Preferences page). But in the second example, if we wanted to automate it, where do we log in? Which step takes on that task? First or second? Which step takes on the task of actually navigating to the My Preferences page?
I also can see issues with reusing steps in unrelated steps. If we add behaviours to steps that aren't clarified in the step title, it will cause issues
Anyone have any advice on the line you draw between procedural steps and behavioural with automation in mind?