Duplicate gherkin statements
In my BDD tests, I need perform same actions in different place, the problem is that each scenario should only have Given before When and Then.
Given close the file
Now if I need to close the file after Then... I need to create a duplicate statement with Then close the file, which doesn't make sense and create duplicate code
Is there any way we can link 'close the file' to both Given and Then so it gets linked to the same code.
Solved! Go to Solution.
You mean in the Then statement?
Yes, the function to close the file can be called in Then.
But, when using 'When', sometimes the When statements are common in most tests and not necessarily you will need to call the same function in the common 'When'. So I was thinking if there is a way to avoid duplicate lines in bdd.
Also, calling function internally in Then means the reader won't know if the file was closed.
Depending on what file you are using, there may be methods you can use to check if the file is opened.
What are you BDD statements, and what is it suppoed to do?
@rraghvani Because the same gherkin statement cannot be linked in When Given Then. I will have to call the same methods for each of them and the step definitions will duplicate.
I think this is how the Gherkin binding is designed in test complete.