BDD Step Reuse
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BDD Step Reuse
Hi,
Anyone have any ideas or suggestions for reusing 2 BDD steps that differ only in their keyword?
Given I log in as John Smith
When I log in as John Smith
Would really love this to be either a single step (can I wildcard the Given or When keywords?!) or two steps but one step calls the other:
Given ("I log in as John Smith", function () {
// login code here
});
When ("I log in as John Smith", function () {
// call the Given here, as it already has the necessary code implemented
});
Some BDD libraries also offer a generic 'Step' keyword which matches any step type, but I don't believe TestComplete supports it.
Any help/suggestions greatly appreciated! Trying our best to prevent massive code bloat.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Hm-m-m...
Is there anything that prevents this:
Given ("I log in as John Smith", function () {
login();
});
When ("I log in as John Smith", function () {
login();
});
function login() {
// ...
};
?
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help, Alex.
@loridee, is this what you were looking for?
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Alex,
That solution you proposed is what we are doing already. Yep, it works, so I have accepted as a solution. But it gives us some bloat - instead of two methods, just the Given and When steps, I now have 3 - the Given, the When and the login method. If I have a lot of step reuse that results in a lot of extra methods.
We were just hoping TestComplete BDD had support for one step calling another step, or step binding based on everything but the keywords as some other BDD frameworks do.
Thanks all!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> instead of two methods, just the Given and When steps, I now have 3
From the coding point of view I see nothing bad to have a common reusable function...
...however:
> as some other BDD frameworks do.
Can you name them? I'm interested to read their documentation and see examples.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Froglogic , according to this blog posting. See the final section titled 'Use same step definition for different step types'...
https://www.froglogic.com/blog/design-good-bdd-steps/
