I'm looking for suggestions or best practices here.
Sometimes I would like to give the same regex/phrase for 2 different steps using different prepositions. The case I see often is a phrase that makes sense in both Given
and in Then
steps.
Given
being used for a step that performs and action (to setup the test state).
And Then
being used for a step that verifies the state, but doesn't perform an action. Quite often I find the same phrasing works right for both. An example such phrase is "I am logged in"
Here is a contrived scenario
Scenario: Login is saved between sessions.
Given I am logged in
When I exit the application
And I start the application
Then I am logged in
Of course this doesn't work in the step definitions because cucumber doesn't differentiate between step predicates.
I've toyed with adding 'verify' to all colliding Then
steps, or adding a 'that' to all duplicated Given
steps. But nothing sits right.
Given that I am logged in.
...
Then verify I am logged in.
It works of course, but I feel I'm missing something that doesn't require having the same "extended predicate" for most of my steps.