Duplicate gherkin statements
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Duplicate gherkin statements
Hi All,
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.
For example.
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.
Thank you!
Solved! Go to Solution.
- Labels:
-
BDD Tests
-
Desktop Testing
-
Script Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you not call the same function?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is not a great example, but gives you a rough idea of what you can do without duplicating BDD statements
