16 views
Skip to first unread message

priya lakshmi

unread,
May 22, 2018, 5:31:26 AM5/22/18
to cu...@googlegroups.com
Hi All,

 I am new to Cucumber, i am trying to understand how it does work. I am having basic query, like i am having n number of scenarios that has login as the prerequsite. But i cannot have all scenarios in a single feature file. 
Query1:
In such a case how can i have a step that can be shared across different features? If it is a single feature i can use Background. 
Query2:
There are n number of scenarios distributed across different features having a common step like " launch the xxx webportal". So for this one step definition declared can it be reused for all of the features that has the desired step? Or it should be defined for every features.

Regards,
Priya


Krishna Gundala

unread,
May 22, 2018, 5:36:49 AM5/22/18
to cu...@googlegroups.com
You can have a feature step share among different features.
Have a <common class> name depending on your framework and define common steps in that class.

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

George Dinwiddie

unread,
May 22, 2018, 9:26:55 AM5/22/18
to cu...@googlegroups.com
Priya,

Remember that the scenarios should be describing behavior, not just
exercising the system.

On 5/16/18 6:49 AM, priya lakshmi wrote:
> Hi All,
>
>  I am new to Cucumber, i am trying to understand how it does work. I am
> having basic query, like i am having n number of scenarios that has
> login as the prerequsite. But i cannot have all scenarios in a single
> feature file.
> Query1:
> In such a case how can i have a step that can be shared across different
> features? If it is a single feature i can use Background.


I push such implementation details down into the step definitions (or
the code that the step definitions call), as they're implementation
details rather than an essential part of the focus of the scenario. For
example, if I say

When the library patron visits their past borrowing history

then the step makes it clear that the user is known to the system. If
that requires logging in, the step definition will log them in. The
pseudo-code might look like the following:

patron = getPatron()
login(patron)
browser = getBrowser()
browser.fetchBorrowingHistoryPage()

I would likely encapsulate web interactions into a suite of page
objects, but there are other ways to handle this, also.

> Query2:
> There are n number of scenarios distributed across different features
> having a common step like " launch the xxx webportal". So for this one
> step definition declared can it be reused for all of the features that
> has the desired step? Or it should be defined for every features.

If "launching the webportal" means starting the server, I would likely
start that before beginning the suite of features. I would make it so
that I could execute the scenarios against any webportal that happened
to be running.

If you want to start the webportal within the test framework, you could
do so within a startup hook. Note that it's unusual that all
interactions take place on a freshly started server. You might miss some
differences that occur when the server has been running for awhile and
has served other requests.

- George

P.S. For a deeper treatment of the layering of test automation code,
I've written a book https://leanpub.com/EvolutionaryAnatomy/ with some
advice.

--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages