Reputation: 18046
I have written a lot of steps that cause me to get confused between the Arrange and Assert steps in my code.
For example:
given file A exists
when I rename it
then file B exists
The arrange part of my code should be making a file and the Assert part of my code should be testing for the existance of a file
however because both steps translate as "File X Exists" I keep getting confused and writing assert code in my arrange steps.
How can I phrase things better so that I don't get confused ?
I have thought of using the present tense in the Arrange part of the specflow For example
given I make file A
However the human readable aspect doesn't feel right.
Upvotes: 2
Views: 128
Reputation: 4346
In your given and your then you are expressing a different intent. File A exists
is very concise but not really great for communicating with other people.
There are many ways of writing cucumber. For me, the thing I think about when phrasing "THEN" parts is "what should have happened" - "should" is the important word to me.
How about
Given a file named "0001.mpg" exists
When I rename "0001.mpg" to "dance competition finals.mpg"
Then a file named "dance competition finals.mpg" should exist
Grammatically:
Given ... exists
- is in the simple present tense - i.e. this is true now, and isn't conditional on anything.Then ... should exist
expresses neccessity in the present tense - i.e. if you check right now this instant, then it ought to be so. ("should" is a "deontic" modal verb according to english stackexchange)Upvotes: 4