Discussion:
[Cucumber] Along with Given, When, Then and And keywords, is there a good reason not to have an IF keyword
Ramesh Bommaraju
2017-09-12 16:51:09 UTC
Permalink
Feature: An example I was wondering about IF keyword in Gherkin, this
example may not be very good one, please feel free to improve the
question/example

Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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.
Tim Walker
2017-09-13 11:14:40 UTC
Permalink
The main reason is to keep confitional logic out of the expressions and to
keep a simple DSL that product people will embrace. Your example screams
for two scenarios.

Tim
Post by Ramesh Bommaraju
Feature: An example I was wondering about IF keyword in Gherkin, this
example may not be very good one, please feel free to improve the
question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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.
--
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.
George Dinwiddie
2017-09-13 15:22:11 UTC
Permalink
Ramesh,

What Tim said. Avoid conditional or branching logic in scenarios. You're
describing a scenario, not writing a program.

That said, I'm curious about the purpose of the scenario you show.
Perhaps if I saw the other scenarios that accompany it, it would make
more sense. As it is, it seems to reduce to
When I navigate to my profile
Then I am on my profile page
Post by Ramesh Bommaraju
Scenario: I validate I am on profile page
Given I am on homepage
Is this significant? Does the scenario not work from other pages?
Post by Ramesh Bommaraju
When I login as an employee
And I navigate to my profile
Does the login need to immediately precede the navigation? Would
"When an employee navigates to their profile" work as well?

Notice that
1. I avoid the first person, and
2. I realize that the system can't know it's an employee unless
they've logged in.
Post by Ramesh Bommaraju
IF I see a message for out dated password, I update my password
Perhaps this is really the point of the scenario. If it is, the scenario
is not making it clear to me.
Post by Ramesh Bommaraju
Then I validate I am on profile page.
It seems curious to me that being on the profile page is the expected
condition. Is there something about success or failure in updating the
password that's hinted at, but not described, here?

With a little more information, I'd be glad to help you refine this
scenario.

- George
Post by Ramesh Bommaraju
Feature: An example I was wondering about IF keyword in Gherkin, this
example may not be very good one, please feel free to improve the
question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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.
Chuck van der Linden
2017-09-13 17:03:45 UTC
Permalink
On Wednesday, September 13, 2017 at 8:22:19 AM UTC-7, George Dinwiddie
Post by George Dinwiddie
Ramesh,
What Tim said. Avoid conditional or branching logic in scenarios. You're
describing a scenario, not writing a program.
That said, I'm curious about the purpose of the scenario you show.
Perhaps if I saw the other scenarios that accompany it, it would make
more sense. As it is, it seems to reduce to
When I navigate to my profile
Then I am on my profile page
Post by Ramesh Bommaraju
Scenario: I validate I am on profile page
Given I am on homepage
Is this significant? Does the scenario not work from other pages?
Post by Ramesh Bommaraju
When I login as an employee
And I navigate to my profile
Does the login need to immediately precede the navigation? Would
"When an employee navigates to their profile" work as well?
Notice that
1. I avoid the first person, and
2. I realize that the system can't know it's an employee unless
they've logged in.
Post by Ramesh Bommaraju
IF I see a message for out dated password, I update my password
Perhaps this is really the point of the scenario. If it is, the scenario
is not making it clear to me.
Post by Ramesh Bommaraju
Then I validate I am on profile page.
It seems curious to me that being on the profile page is the expected
condition. Is there something about success or failure in updating the
password that's hinted at, but not described, here?
With a little more information, I'd be glad to help you refine this
scenario.
- George
Post by Ramesh Bommaraju
Feature: An example I was wondering about IF keyword in Gherkin, this
example may not be very good one, please feel free to improve the
question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
I'm pretty much with George on this, although I see a larger number of
scenarios I'm not going to spell out all the steps, but I think those are
fairly obvious

All these would have a Given step, "Given there is an employee with an
expired password" which would set you up with an employee user object
who's password is expired. following steps can then make use of that user.

Scenario: Employee with expired password see's proper notification of such
on login
Scenario: Employee with expired password can successfully update password
with a new unique password
Scenario: Employee with expired password cannot re-use existing password
when updating their password

Likely other scenarios around password complexity, not containing their
username, etc. However, I would expect existing tests for initial password
validation covers that functionality already
--
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.
Koen Prins
2017-09-13 05:11:06 UTC
Permalink
Yes, there is a very good reason for this as it introduces multiple paths
in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an IF
statement, you are creating an uncertainty that both tests are run with a
dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.

In general, you want your tests to have at least the following:
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can maintain
them
Executable: A single test can be run over and over again without the need
of manual interaction

Basically, your tests need to taste well :-) Like code smell but for tests
;-)
Post by Ramesh Bommaraju
Feature: An example I was wondering about IF keyword in Gherkin, this
example may not be very good one, please feel free to improve the
question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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.
George Dinwiddie
2017-09-13 23:02:01 UTC
Permalink
There's one of those mnemonics that Gabriel Oliveira is looking for. :-)

- George
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple
paths in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an IF
statement, you are creating an uncertainty that both tests are run with
a dependency on (I assume) testdata. Now you have to control your
testdata but if you control your testdata, you are better off by setting
the data for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the
need of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
Feature: An example I was wondering about IF keyword in Gherkin,
this example may not be very good one, please feel free to improve
the question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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
For more options, visit https://groups.google.com/d/optout.
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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.
Gabriel Oliveira
2017-09-14 08:43:57 UTC
Permalink
Thank you George for calling my attention :) sent a private message to Koen
about those nice criteria of his.
Post by George Dinwiddie
There's one of those mnemonics that Gabriel Oliveira is looking for. :-)
- George
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple paths
in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an IF
statement, you are creating an uncertainty that both tests are run with a
dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the need
of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
Feature: An example I was wondering about IF keyword in Gherkin,
this example may not be very good one, please feel free to improve
the question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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.
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
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.
Tim Walker
2017-09-15 19:39:40 UTC
Permalink
Something I would like to point out is the "triple" by Tony Hoare {P}c{Q}.
Do we really even need And and But?
Post by George Dinwiddie
There's one of those mnemonics that Gabriel Oliveira is looking for. :-)
- George
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple paths
in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an IF
statement, you are creating an uncertainty that both tests are run with a
dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the need
of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
Feature: An example I was wondering about IF keyword in Gherkin,
this example may not be very good one, please feel free to improve
the question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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.
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
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.
aslak hellesoy
2017-09-15 22:37:05 UTC
Permalink
From a logical perspective, "And" and "But" are identical - they're
conjunctions that combine several conditions into one. From a gramatical
perspective they're different - But is for expressing something negative.
For example:

{C} = "The passenger has a ticket" And "the passenger has checked in"
{C} = "The passenger has a ticket" But "the passenger has not checked in"

And and But are not needed if you combine them into a single step, but this
is impractical both for a readability and implementation.

Aslak
Post by Tim Walker
Something I would like to point out is the "triple" by Tony Hoare {P}c{Q}.
Do we really even need And and But?
Post by George Dinwiddie
There's one of those mnemonics that Gabriel Oliveira is looking for. :-)
- George
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple
paths in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an IF
statement, you are creating an uncertainty that both tests are run with a
dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the
need of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
Feature: An example I was wondering about IF keyword in Gherkin,
this example may not be very good one, please feel free to improve
the question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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
For more options, visit https://groups.google.com/d/optout.
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
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
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.
Tim Walker
2017-09-16 14:18:43 UTC
Permalink
Post by aslak hellesoy
From a logical perspective, "And" and "But" are identical - they're
conjunctions that combine several conditions into one. From a gramatical
perspective they're different - But is for expressing something negative.
{C} = "The passenger has a ticket" And "the passenger has checked in"
{C} = "The passenger has a ticket" But "the passenger has not checked in"
And and But are not needed if you combine them into a single step, but this
Post by aslak hellesoy
is impractical both for a readability and implementation.
Great point. It makes me wonder, and I mean really wonder (I have no
idea).

"If" seems to be a valid "assertion" in natural language (as well as it is
a branch construct in programming languages).

I mean:

"If the customer's bank account is $0"
"Then don't allow him to withdraw any money"

We would "probably more naturally" use "If" than "Given". Does that, by
definition, make it "more expressive"?. Does the fact that a specification
has GWT make it easier to "spot" it, or less so because seeing a whole lot
of GWTs makes it not read as well, but has always been "precise" to me.

In the Hoare predicate the {P} and {Q} are assertions. We assert the state,
operate on the state and assert the new state. Isn't if as valid an
assertion as given? Should Given/If mean the same thing and what damned
slippery slope would this take us down? Tim
Post by aslak hellesoy
Aslak
Post by Tim Walker
Something I would like to point out is the "triple" by Tony Hoare
{P}c{Q}. Do we really even need And and But?
Post by George Dinwiddie
There's one of those mnemonics that Gabriel Oliveira is looking for. :-)
- George
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple
paths in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an
IF statement, you are creating an uncertainty that both tests are run with
a dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the
need of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
Feature: An example I was wondering about IF keyword in Gherkin,
this example may not be very good one, please feel free to improve
the question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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
For more options, visit https://groups.google.com/d/optout.
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
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
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
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.
Andrew Premdas
2017-09-16 15:52:38 UTC
Permalink
Using If as a synonym of Given is just asking for trouble ;) Whilst in a
natural language context it might be OK, in any context to do with
programming IF is always going to be seen as conditional first of all and
everyone is going to expect ELSE to be coming along with it.
Post by aslak hellesoy
Post by aslak hellesoy
From a logical perspective, "And" and "But" are identical - they're
conjunctions that combine several conditions into one. From a gramatical
perspective they're different - But is for expressing something negative.
{C} = "The passenger has a ticket" And "the passenger has checked in"
{C} = "The passenger has a ticket" But "the passenger has not checked in"
And and But are not needed if you combine them into a single step, but
Post by aslak hellesoy
this is impractical both for a readability and implementation.
Great point. It makes me wonder, and I mean really wonder (I have no
idea).
"If" seems to be a valid "assertion" in natural language (as well as it is
a branch construct in programming languages).
"If the customer's bank account is $0"
"Then don't allow him to withdraw any money"
We would "probably more naturally" use "If" than "Given". Does that, by
definition, make it "more expressive"?. Does the fact that a specification
has GWT make it easier to "spot" it, or less so because seeing a whole lot
of GWTs makes it not read as well, but has always been "precise" to me.
In the Hoare predicate the {P} and {Q} are assertions. We assert the
state, operate on the state and assert the new state. Isn't if as valid an
assertion as given? Should Given/If mean the same thing and what damned
slippery slope would this take us down? Tim
Post by aslak hellesoy
Aslak
Post by Tim Walker
Something I would like to point out is the "triple" by Tony Hoare
{P}c{Q}. Do we really even need And and But?
Post by George Dinwiddie
There's one of those mnemonics that Gabriel Oliveira is looking for. :-)
- George
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple
paths in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an
IF statement, you are creating an uncertainty that both tests are run with
a dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the
need of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
Feature: An example I was wondering about IF keyword in Gherkin,
this example may not be very good one, please feel free to improve
the question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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
For more options, visit https://groups.google.com/d/optout.
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
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
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
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
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.
Tim Walker
2017-09-18 12:45:35 UTC
Permalink
Post by Andrew Premdas
Using If as a synonym of Given is just asking for trouble ;) Whilst in a
natural language context it might be OK, in any context to do with
programming IF is always going to be seen as conditional first of all and
everyone is going to expect ELSE to be coming along with it.
Oh yeah, in the current mindset and where we are at here...for sure. I'd
never suggest the IF. OTOH I have yet to see a "real, in the wild, all
natural-language" use of "Given..." (Except, perhaps from Thurston Howell
III). Nobody talks like that! When you look at many features and scenarios,
all starting with GWT, I do see people checking out. They are and not
getting the power of what's going on here. When you look at the awesome
"living specification" of RSPec on Relishapp, the whole thing hides the
underlying GWT. It is compelling as documentation. Where will all this go
in the future? What about unconstrained natural language guided by
examples? Thanks for the dialogue Andrew. Tim
Post by Andrew Premdas
Post by aslak hellesoy
Post by aslak hellesoy
From a logical perspective, "And" and "But" are identical - they're
conjunctions that combine several conditions into one. From a gramatical
perspective they're different - But is for expressing something negative.
{C} = "The passenger has a ticket" And "the passenger has checked in"
{C} = "The passenger has a ticket" But "the passenger has not checked in"
And and But are not needed if you combine them into a single step, but
Post by aslak hellesoy
this is impractical both for a readability and implementation.
Great point. It makes me wonder, and I mean really wonder (I have no
idea).
"If" seems to be a valid "assertion" in natural language (as well as it
is a branch construct in programming languages).
"If the customer's bank account is $0"
"Then don't allow him to withdraw any money"
We would "probably more naturally" use "If" than "Given". Does that, by
definition, make it "more expressive"?. Does the fact that a specification
has GWT make it easier to "spot" it, or less so because seeing a whole lot
of GWTs makes it not read as well, but has always been "precise" to me.
In the Hoare predicate the {P} and {Q} are assertions. We assert the
state, operate on the state and assert the new state. Isn't if as valid an
assertion as given? Should Given/If mean the same thing and what damned
slippery slope would this take us down? Tim
Post by aslak hellesoy
Aslak
Post by Tim Walker
Something I would like to point out is the "triple" by Tony Hoare
{P}c{Q}. Do we really even need And and But?
Post by George Dinwiddie
There's one of those mnemonics that Gabriel Oliveira is looking for. :-)
- George
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple
paths in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an
IF statement, you are creating an uncertainty that both tests are run with
a dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the
need of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
Feature: An example I was wondering about IF keyword in Gherkin,
this example may not be very good one, please feel free to improve
the question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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,
For more options, visit https://groups.google.com/d/optout.
--
-----------------------------------------------------------
-----------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.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
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
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
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
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
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.
aslak hellesoy
2017-09-18 13:35:32 UTC
Permalink
Cucumber is a tool support BDD.

BDD (being a variant of TDD) implies you're in *full* control of the entire
system's state, which is set up in Given steps. There is no
non-determinism, and therefore no need for "If".

When Cucumber is used against a system whose state is not under control of
Givens (such as some external database updated nilly willy by anyone),
there is non-determinism. I can see why people want If in this case. The
thing is, Cucumber was never meant to be used as a testing tool, even less
as a testing tool for non-deterministic systems.

Aslak
Post by Tim Walker
Post by Andrew Premdas
Using If as a synonym of Given is just asking for trouble ;) Whilst in a
natural language context it might be OK, in any context to do with
programming IF is always going to be seen as conditional first of all and
everyone is going to expect ELSE to be coming along with it.
Oh yeah, in the current mindset and where we are at here...for sure. I'd
never suggest the IF. OTOH I have yet to see a "real, in the wild, all
natural-language" use of "Given..." (Except, perhaps from Thurston Howell
III). Nobody talks like that! When you look at many features and scenarios,
all starting with GWT, I do see people checking out. They are and not
getting the power of what's going on here. When you look at the awesome
"living specification" of RSPec on Relishapp, the whole thing hides the
underlying GWT. It is compelling as documentation. Where will all this go
in the future? What about unconstrained natural language guided by
examples? Thanks for the dialogue Andrew. Tim
Post by Andrew Premdas
On Fri, Sep 15, 2017 at 4:37 PM, aslak hellesoy <
Post by aslak hellesoy
From a logical perspective, "And" and "But" are identical - they're
conjunctions that combine several conditions into one. From a gramatical
perspective they're different - But is for expressing something negative.
{C} = "The passenger has a ticket" And "the passenger has checked in"
{C} = "The passenger has a ticket" But "the passenger has not checked in"
And and But are not needed if you combine them into a single step, but
Post by aslak hellesoy
this is impractical both for a readability and implementation.
Great point. It makes me wonder, and I mean really wonder (I have no
idea).
"If" seems to be a valid "assertion" in natural language (as well as it
is a branch construct in programming languages).
"If the customer's bank account is $0"
"Then don't allow him to withdraw any money"
We would "probably more naturally" use "If" than "Given". Does that, by
definition, make it "more expressive"?. Does the fact that a specification
has GWT make it easier to "spot" it, or less so because seeing a whole lot
of GWTs makes it not read as well, but has always been "precise" to me.
In the Hoare predicate the {P} and {Q} are assertions. We assert the
state, operate on the state and assert the new state. Isn't if as valid an
assertion as given? Should Given/If mean the same thing and what damned
slippery slope would this take us down? Tim
Post by aslak hellesoy
Aslak
Post by Tim Walker
Something I would like to point out is the "triple" by Tony Hoare
{P}c{Q}. Do we really even need And and But?
Post by George Dinwiddie
There's one of those mnemonics that Gabriel Oliveira is looking for. :-)
- George
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple
paths in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing
an IF statement, you are creating an uncertainty that both tests are run
with a dependency on (I assume) testdata. Now you have to control your
testdata but if you control your testdata, you are better off by setting
the data for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the
need of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
Feature: An example I was wondering about IF keyword in Gherkin,
this example may not be very good one, please feel free to improve
the question/example
Scenario: I validate I am on profile page
Given I am on homepage
When I login as an employee
And I navigate to my profile
IF I see a message for out dated password, I update my password
Then I validate I am on profile page.
--
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,
For more options, visit https://groups.google.com/d/optout.
--
-----------------------------------------------------------
-----------
* George Dinwiddie *
http://blog.gdinwiddie.com
Software Development
http://www.idiacomputing.com
Consultant and Coach
http://www.agilemaryland.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,
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
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
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
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
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
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.
Chuck van der Linden
2017-09-18 16:38:00 UTC
Permalink
Post by Tim Walker
Post by Andrew Premdas
Using If as a synonym of Given is just asking for trouble ;) Whilst in a
natural language context it might be OK, in any context to do with
programming IF is always going to be seen as conditional first of all and
everyone is going to expect ELSE to be coming along with it.
Oh yeah, in the current mindset and where we are at here...for sure. I'd
never suggest the IF. OTOH I have yet to see a "real, in the wild, all
natural-language" use of "Given..." (Except, perhaps from Thurston Howell
III). Nobody talks like that! When you look at many features and scenarios,
all starting with GWT, I do see people checking out. They are and not
getting the power of what's going on here. When you look at the awesome
"living specification" of RSPec on Relishapp, the whole thing hides the
underlying GWT. It is compelling as documentation. Where will all this go
in the future? What about unconstrained natural language guided by
examples? Thanks for the dialogue Andrew. Tim
Post by Andrew Premdas
Post by aslak hellesoy
Post by aslak hellesoy
From a logical perspective, "And" and "But" are identical - they're
conjunctions that combine several conditions into one. From a gramatical
perspective they're different - But is for expressing something negative.
{C} = "The passenger has a ticket" And "the passenger has checked in"
{C} = "The passenger has a ticket" But "the passenger has not checked in"
And and But are not needed if you combine them into a single step, but
Post by aslak hellesoy
this is impractical both for a readability and implementation.
Great point. It makes me wonder, and I mean really wonder (I have no
idea).
"If" seems to be a valid "assertion" in natural language (as well as it
is a branch construct in programming languages).
"If the customer's bank account is $0"
"Then don't allow him to withdraw any money"
We would "probably more naturally" use "If" than "Given". Does that, by
definition, make it "more expressive"?. Does the fact that a specification
has GWT make it easier to "spot" it, or less so because seeing a whole lot
of GWTs makes it not read as well, but has always been "precise" to me.
In the Hoare predicate the {P} and {Q} are assertions. We assert the
state, operate on the state and assert the new state. Isn't if as valid an
assertion as given? Should Given/If mean the same thing and what damned
slippery slope would this take us down? Tim
I think the best place for IF in a scenario like that is in the scenario
title

Scenario: Refuse withdrawals if the user's account balance is zero
. Given Jim's account has a balance of $0
. When Jim attempts to withdraw $10
. Then the withdrawal is refused
. And Jim see's a message indicating why the withdrawal was refused
--
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.
Chuck van der Linden
2017-09-15 16:47:35 UTC
Permalink
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple paths
in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an IF
statement, you are creating an uncertainty that both tests are run with a
dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can maintain
them
Executable: A single test can be run over and over again without the need
of manual interaction
Basically, your tests need to taste well :-) Like code smell but for tests
;-)
That's wonderful stuff, do you know who originated that mnemonic? I'd love
to credit it properly when passing it along
--
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.
Koen Prins
2017-09-15 17:56:04 UTC
Permalink
Post by Chuck van der Linden
Post by Koen Prins
Yes, there is a very good reason for this as it introduces multiple paths
in a single test and this is generally considered a Bad Thing.
Let's say that both situations are valid testcases. By introducing an IF
statement, you are creating an uncertainty that both tests are run with a
dependency on (I assume) testdata. Now you have to control your testdata
but if you control your testdata, you are better off by setting the data
for both cases and create two scripts, both covering a single case.
Transparancy: It has to be clear what they do and how they do it
Atomic: They have to test a single thing and only that thing.
Singular: They do not build on other testcases for setting of testdata
Transferable: The tests are written in such a way that others can
maintain them
Executable: A single test can be run over and over again without the need
of manual interaction
Basically, your tests need to taste well :-) Like code smell but for
tests ;-)
That's wonderful stuff, do you know who originated that mnemonic? I'd love
to credit it properly when passing it along
I made it up for this reply, it is not perfect but was put together as a
tongue in cheek way to tell OP not to build his tests on top of each other.
Also, we stand on the shoulders of giants so view it as open source /
common domain.
--
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...