Discussion:
[Cucumber] Cucumber--How to use an optional Background...
PREETHU D
2017-01-13 10:47:59 UTC
Permalink
Hi everyone,

We want to automate certain features with valid login as a precondition . I
have mentioned this precondition as a background in the feature files. Im
maintaining a login functionality in a separate feature file.Please advice
how to link my login feature with other scenarios.(Basically i don't want
to duplicate the login related script in other scenario scripts since i'm
having a separate login script).
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Andrew Premdas
2017-01-13 13:43:37 UTC
Permalink
Any scenario that has being logged in as a precondition, should say so e.g.

Given I am logged in
When I foo
Then I should see I have foo'd

You should NEVER link feature files.

Its incredibly important that each individual scenario specifies its
preconditions e.g. who you are and what your state is. Without this your
scenarios will not make sense.

e.g.

Given I am not logged in
When I foo
Then I should see that I can't foo unless I am logged in.

If we take out the Givens from the example scenarios we get

When I foo
Then I should see I have foo'd

When I foo
Then I should see that I can't foo unless I am logged in.

which are clearly contradictory.
Post by PREETHU D
Hi everyone,
We want to automate certain features with valid login as a precondition .
I have mentioned this precondition as a background in the feature files. Im
maintaining a login functionality in a separate feature file.Please advice
how to link my login feature with other scenarios.(Basically i don't want
to duplicate the login related script in other scenario scripts since i'm
having a separate login script).
--
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
For more options, visit https://groups.google.com/d/optout.
--
------------------------
Andrew Premdas
blog.andrew.premdas.org
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Justin Radcliffe
2017-01-14 13:16:04 UTC
Permalink
We have out login and logo it's in A Hooks file. Before and AfterClass methods. We also can control by tags if we want to run this or not per scenario. So we can tag @UI to use the login or @API to not have the login for API testing.

I can share code if wanted.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Roberto Lo Giacco
2017-01-15 10:17:12 UTC
Permalink
The solution we adopted is to use our Given step to define the user in
business terms (not login credentials), so that it is clear what type of
user is operating.
This is a consequence of the fact the UI changes depending on specific
conditions determined upon login:

Given I am a customer with multiple contracts
When I access the My Contracts section
Then I get a list of contracts to choose from
And I can select the contract to display

Given I am a customer with only one contract
When I access the My Contracts section
Then the contract details are displayed

Given I am a customer with no running contracts
When I access the My Contracts section
Then a warning is displayed stating "You have no running contracts"

Given I am a prospect customer
Then the My Contracts section is disabled



Whenever the customer type is not relevant for the functionality we just
use a generic background step

Given I'm a non banned customer


Il giorno sabato 14 gennaio 2017 14:16:04 UTC+1, Justin Radcliffe ha
Post by Justin Radcliffe
We have out login and logo it's in A Hooks file. Before and AfterClass
methods. We also can control by tags if we want to run this or not per
for API testing.
I can share code if wanted.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Justin Radcliffe
2017-01-15 13:41:51 UTC
Permalink
Couldn't you just split those into separate feature files and then they could all use the background needed for that set of scenarios?

Sent from my iPhone
The solution we adopted is to use our Given step to define the user in business terms (not login credentials), so that it is clear what type of user is operating.
Given I am a customer with multiple contracts
When I access the My Contracts section
Then I get a list of contracts to choose from
And I can select the contract to display
Given I am a customer with only one contract
When I access the My Contracts section
Then the contract details are displayed
Given I am a customer with no running contracts
When I access the My Contracts section
Then a warning is displayed stating "You have no running contracts"
Given I am a prospect customer
Then the My Contracts section is disabled
Whenever the customer type is not relevant for the functionality we just use a generic background step
Given I'm a non banned customer
Post by Justin Radcliffe
I can share code if wanted.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to a topic in the Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cukes/rjCqdGF0mbc/unsubscribe.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Roberto Lo Giacco
2017-01-15 13:50:57 UTC
Permalink
I want a file "per feature" not a file "per user type". I could split in a
file "per feature per user type" but I'll probably end up with one or two
scenarios per feature file and a proliferation of cumbersome feature files
like 'contracts-for-no-contracts-customer.feature'.... (argh!)

Also, it really depends on how your business partners are used to think
about the business THEY OWN/RUN: in my case they think about contract
management and the different customers are just.... scenarios. So that is
what we reported into our live documentation.

I feel the scenarios I reported read quite easily and they are also pretty
easy to implement: if any of the post-login steps need to know who is the
current user they access a scenario-shared memory area to retrieve info
about the current user.
Post by Justin Radcliffe
Couldn't you just split those into separate feature files and then they
could all use the background needed for that set of scenarios?
Sent from my iPhone
The solution we adopted is to use our Given step to define the user in
business terms (not login credentials), so that it is clear what type of
user is operating.
This is a consequence of the fact the UI changes depending on specific
Given I am a customer with multiple contracts
When I access the My Contracts section
Then I get a list of contracts to choose from
And I can select the contract to display
Given I am a customer with only one contract
When I access the My Contracts section
Then the contract details are displayed
Given I am a customer with no running contracts
When I access the My Contracts section
Then a warning is displayed stating "You have no running contracts"
Given I am a prospect customer
Then the My Contracts section is disabled
Whenever the customer type is not relevant for the functionality we just
use a generic background step
Given I'm a non banned customer
Post by Justin Radcliffe
We have out login and logo it's in A Hooks file. Before and AfterClass
methods. We also can control by tags if we want to run this or not per
for API testing.
I can share code if wanted.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to a topic in the
Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/to
pic/cukes/rjCqdGF0mbc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to a topic in the
Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/to
pic/cukes/rjCqdGF0mbc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...