Discussion:
[Cucumber] Scenario Outline creating too many step definitions
(too old to reply)
Christian Baumann
2018-04-17 11:42:41 UTC
Permalink
Raw Message
Hi all,

I have the following in my scenario outline (IÂŽm using Ruby Cucumber):

Then I can select the <position> entry from the auto-completion list via
<selection-method>

Examples:
| position | selection-method |
| 1 | Enter |
| 2 | Arrow keys |

When I run the feature without any step definitions defined, I get two step
definitions proposed to create:

You can implement step definitions for undefined steps with these snippets:

Then("I can select the {int} entry from the auto-completion list via
Enter") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end

You can implement step definitions for undefined steps with these snippets:

Then("I can select the {int} entry from the auto-completion list via Arrow
keys") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end

Instead I would expect something like Then("I can select the {string} entry
from the auto-completion list via {string}") do |string, string|
ItÂŽs not working when I just create that single step definition.

Any ideas?

Many thanks,
Christian
--
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.
Mo Hijazi
2018-04-17 16:36:33 UTC
Permalink
Raw Message
Try

Then("I can select the {int} entry from the auto-completion list via (\w+)")
do |int|
Post by Christian Baumann
Hi all,
Then I can select the <position> entry from the auto-completion list via
<selection-method>
| position | selection-method |
| 1 | Enter |
| 2 | Arrow keys |
When I run the feature without any step definitions defined, I get two
Then("I can select the {int} entry from the auto-completion list via
Enter") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Then("I can select the {int} entry from the auto-completion list via Arrow
keys") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Instead I would expect something like Then("I can select the {string}
entry from the auto-completion list via {string}") do |string, string|
ItÂŽs not working when I just create that single step definition.
Any ideas?
Many thanks,
Christian
--
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.
Mo Hijazi
2018-04-17 16:38:09 UTC
Permalink
Raw Message
Try:

Then("I can select the {int} entry from the auto-completion list via (\w+)")
do |int, word|

or if you don't care about capturing the last word:

Then("I can select the {int} entry from the auto-completion list via \w+")
do |int|
Post by Christian Baumann
Hi all,
Then I can select the <position> entry from the auto-completion list via
<selection-method>
| position | selection-method |
| 1 | Enter |
| 2 | Arrow keys |
When I run the feature without any step definitions defined, I get two
Then("I can select the {int} entry from the auto-completion list via
Enter") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Then("I can select the {int} entry from the auto-completion list via Arrow
keys") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Instead I would expect something like Then("I can select the {string}
entry from the auto-completion list via {string}") do |string, string|
ItÂŽs not working when I just create that single step definition.
Any ideas?
Many thanks,
Christian
--
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.
Björn Rasmusson
2018-04-17 17:03:53 UTC
Permalink
Raw Message
Post by Christian Baumann
Hi all,
Then I can select the <position> entry from the auto-completion list via
<selection-method>
| position | selection-method |
| 1 | Enter |
| 2 | Arrow keys |
When I run the feature without any step definitions defined, I get two
Then("I can select the {int} entry from the auto-completion list via
Enter") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Then("I can select the {int} entry from the auto-completion list via Arrow
keys") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Instead I would expect something like Then("I can select the {string}
entry from the auto-completion list via {string}") do |string, string|
ItÂŽs not working when I just create that single step definition.
{string} in a Cucumber Expression captures text within "". So the step
definition:
Then("I can select the {string} entry from the auto-completion list via
{string}") do |string, string|

does match steps like:
Then I can select the "1" entry from the auto-completion list via "Enter"

but the two step you have are (after the outline step has been instantiated
using the examples table):
Then I can select the 1 entry from the auto-completion list via Enter
Then I can select the 2 entry from the auto-completion list via Arrow keys

If you change the outline step to:
Then I can select the "<position>" entry from the auto-completion list via
"<selection-method>"

your step definition will match your (instantiated) steps.

/Björn
Post by Christian Baumann
Any ideas?
Many thanks,
Christian
--
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
2018-04-17 18:55:18 UTC
Permalink
Raw Message
Post by Christian Baumann
Hi all,
Then I can select the <position> entry from the auto-completion list via
<selection-method>
| position | selection-method |
| 1 | Enter |
| 2 | Arrow keys |
When I run the feature without any step definitions defined, I get two
Then("I can select the {int} entry from the auto-completion list via
Enter") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Then("I can select the {int} entry from the auto-completion list via Arrow
keys") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Instead I would expect something like Then("I can select the {string}
entry from the auto-completion list via {string}") do |string, string|
The {string} parameter type requires the string to be surrounded in single
or double quotes. You could use the following expression:

Given("I can select the {int} entry from the auto-completion list via
{string}")

But you would also have to say the following in order to make it match:

Given I can select the 1 entry from the auto-completion list via "Arrow
keys"

Or, because you're using Scenario Outline:

Given I can select the <position> entry from the auto-completion list via
"<selection-method>"

Cucumber performs the substitution of <> parameters before the step is
matched, anb before snippets are generated.
Cucumber does not keep track of what the step was before this substitution,
and doesn't keep track of the Scenario Outline
parameters after the substitution.

That's why the <> parameters don't affect what step definition is matched,
or what snippet is generated. This is done
purely based on what the step looks like after substitution.

Aslak

ItÂŽs not working when I just create that single step definition.
Post by Christian Baumann
Any ideas?
Many thanks,
Christian
--
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.
Christian Baumann
2018-04-18 07:03:26 UTC
Permalink
Raw Message
Thanks all,

changing the step to Then I can select the <position> entry from the
auto-completion list via "<selection-method>"
works with the step definition Then("I can select the {int} entry from the
auto-completion list via {string}") do |int, string|

Best,
Christian

--
*Christian Baumann*
Clara-Viebig-Straße 2 | D-54634 Bitburg
Phone: +49 (0) 65 61 / 69 40 52 7 | Mobile: +49 (0) 17 3 / 58 12 37 4
*Public PGP Key*: http://chriss-baumann.de/pgp.html | Was ist PGP und wie
funktioniert es?
<https://www.datenschutzzentrum.de/selbstdatenschutz/internet/pgp/wasdas.htm>
Post by aslak hellesoy
Post by Christian Baumann
Hi all,
Then I can select the <position> entry from the auto-completion list via
<selection-method>
| position | selection-method |
| 1 | Enter |
| 2 | Arrow keys |
When I run the feature without any step definitions defined, I get two
Then("I can select the {int} entry from the auto-completion list via
Enter") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Then("I can select the {int} entry from the auto-completion list via
Arrow keys") do |int|
pending # Write code here that turns the phrase above into concrete
actions
end
Instead I would expect something like Then("I can select the {string}
entry from the auto-completion list via {string}") do |string, string|
The {string} parameter type requires the string to be surrounded in single
Given("I can select the {int} entry from the auto-completion list via
{string}")
Given I can select the 1 entry from the auto-completion list via "Arrow
keys"
Given I can select the <position> entry from the auto-completion list
via "<selection-method>"
Cucumber performs the substitution of <> parameters before the step is
matched, anb before snippets are generated.
Cucumber does not keep track of what the step was before this
substitution, and doesn't keep track of the Scenario Outline
parameters after the substitution.
That's why the <> parameters don't affect what step definition is matched,
or what snippet is generated. This is done
purely based on what the step looks like after substitution.
Aslak
ItÂŽs not working when I just create that single step definition.
Post by Christian Baumann
Any ideas?
Many thanks,
Christian
--
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.
Loading...