[Cucumber] a few clarifications please


#1

Hi Guys,

Things are working great with Cucumber and am getting better at
expressing requirements as behaviors. Kudos!

I seek a couple of points of clarification, or confirmation, if
someone has a minute or two…

FWIW - I’ve read the wiki and the given-when-then page and just seek
confirmation:

There is no dependency implied in the keywords “given”, “then” and
“when” (as well as “and” and "but), correct? These are simply naming
conventions that denote the well known “Build/Operate/Check” pattern
but have no real physical relationship, they’re just tags that denote
the steps.

A “pending” step is any step that has a matching step but nothing is
implemented.

A “successful” step is any step that is matched, has some code and
doesn’t assert anything resolving to false.

A “gray” out step means that no steps were found that matched the
feature.

You need to be careful that features do not match steps in the step
file or cucumber will execute the first step it finds that matches
(really don’t know how this works, will a test sequence ever go
‘backwards’?)

Going back and changing the stuff in the .feature file is risky as
it’s very easy to create a mismatch and the step won’t be found.

Thanks very much,

Tim


#2

Thank you David. This helps a lot. Question, if there are matching
steps…will cucumber find the first matching step during execution? I
noticed a test executing at higher line numbers and then picking up a
step with a lower line number.

Thanks again,

Tim


#3

On Wed, Dec 17, 2008 at 2:34 PM, Tim W. removed_email_address@domain.invalid wrote:

There is no dependency implied in the keywords “given”, “then” and
“when” (as well as “and” and "but), correct? These are simply naming
conventions that denote the well known “Build/Operate/Check” pattern
but have no real physical relationship, they’re just tags that denote
the steps.

Correct.

A “pending” step is any step that has a matching step but nothing is
implemented.

Correct.

A “successful” step is any step that is matched, has some code and
doesn’t assert anything resolving to false.

Or raise an error.

A “gray” out step means that no steps were found that matched the feature.

Blue? Means that a step was found, but a previous step was either
pending or failed.

You need to be careful that features do not match steps in the step
file or cucumber will execute the first step it finds that matches
(really don’t know how this works, will a test sequence ever go
‘backwards’?)

Cucumber tells you when it finds two steps definitions that could
match the step in the feature.

Going back and changing the stuff in the .feature file is risky as
it’s very easy to create a mismatch and the step won’t be found.

Not sure why that is risky, unless you mean that there are
non-developers making these changes. If so, then they should probably
be made collaboratively.


#4

On Wed, Dec 17, 2008 at 3:37 PM, Tim W. removed_email_address@domain.invalid wrote:

Thank you David. This helps a lot. Question, if there are matching
steps…will cucumber find the first matching step during execution? I
noticed a test executing at higher line numbers and then picking up a
step with a lower line number.

Again, cucumber looks at all of the steps and throws an error if more
than one will match your step. So order should not be an issue.


#5

On Wed, Dec 17, 2008 at 10:53 PM, David C.
removed_email_address@domain.invalidwrote:

Thanks again,

the steps.

Correct.

A “pending” step is any step that has a matching step but nothing is
implemented.

Correct.

A “pending” step (plain text) is any step that does not have a
matching
step definition (regexp+proc).
-Or (as of 0.1.13) a matching step definition that raises Pending (for
example by calling #pending).

pending or failed.

it’s very easy to create a mismatch and the step won’t be found.

Not sure why that is risky, unless you mean that there are
non-developers making these changes. If so, then they should probably
be made collaboratively.

Every time something is changed, you run Cucumber immediately, and then
you’ll know if you broke something.

Aslak


#6

Great information guys, making some progress on this end. It is much
appreciated.

Discovered that step definitions can not be duplicated even across
step files. Is this correct?

Thanks again.

Sincerely,

Tim


#7

David C. wrote:

FWIW - I’ve read the wiki and the given-when-then page and just seek

A “pending” step is any step that has a matching step but nothing is
implemented.

Correct.

In the latest version in Github (0.1.13) you can also force steps which
have an implementation to the pending state using the ‘pending’ method
which works in the same way as Rspec’s pending.

When “I want to be lazy” do
pending “Implement me!”
end


Joseph W.
http://blog.josephwilk.net


#8

Tim W. wrote:

Great information guys, making some progress on this end. It is much
appreciated.

Discovered that step definitions can not be duplicated even across
step files. Is this correct?

Correct. They can’t be duplicated in any given process, no mater what
file(s) the definitions come from.

-Ben


#9

On Wed, Dec 17, 2008 at 11:50 PM, Tim W. removed_email_address@domain.invalid wrote:

Great information guys, making some progress on this end. It is much
appreciated.

Discovered that step definitions can not be duplicated even across
step files. Is this correct?

Regexen can not be the same (even if the blocks are different). I just
refactored the wiki a little and added a new page about this:
http://github.com/aslakhellesoy/cucumber/wikis/step-definitions

Aslak


#10

What about two steps with the same regex but are of different types –
i.e.
a Given and a Then with the same regexp?
Steve


#11

On Wed, Dec 17, 2008 at 8:30 PM, Steve M. removed_email_address@domain.invalid
wrote:

What about two steps with the same regex but are of different types – i.e.
a Given and a Then with the same regexp?

They do the exact same thing. Given|When|Then is just a nicety for you
as the developer. Cucumber could care less. This is the code from
Cucumber:

def Given(key, &proc)
  step_mother.register_step_proc(key, &proc)
end

def When(key, &proc)
  step_mother.register_step_proc(key, &proc)
end

def Then(key, &proc)
  step_mother.register_step_proc(key, &proc)
end

Thanks again.

wrote:

FWIW - I’ve read the wiki and the given-when-then page and just seek

have

A “gray” out step means that no steps were found that matched the
(really don’t know how this works, will a test sequence ever go


http://rubyforge.org/mailman/listinfo/rspec-users
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/rspec-users


Zach D.
http://www.continuousthinking.com
http://www.mutuallyhuman.com