ma...@mattwynne.net
07974 430184
Andrew, are you going to hold up your sign? ;)
There's been quite a bit of discussion about this before. A lot of us feel that nesting steps like this is a bit of an anti-pattern. Search the group for posts by Andrew Premdas and you'll get the picture.
This isn't obviously a great reason, but I also suspect this would be pretty awkward to build, and right now the internals of Cucumber are gradually being cleaned up. Until that's done it's hard for us to really even think about building this kind of thing.
cheers,
Matt
Search the group for posts by Andrew Premdas and you'll get the picture.
This isn't obviously a great reason, but I also suspect this would be pretty awkward to build, and right now the internals of Cucumber are gradually being cleaned up. Until that's done it's hard for us to really even think about building this kind of thing.
cheers,
Matt
http://blog.mattwynne.net
--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cu...@googlegroups.com.
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
I disagree. The advantage of *Gherkin* is that it is readable by
non-programmers. The implementation language is the implementation
language, and if it is constrained by requirements that it, too, be
readable by non-programmers, we're all going to be in a lot of
trouble. If your client is asking what is happening in a given
scenario or why, then that is a sign that the scenario is missing some
information that it doesn't currently include. This can change between
clients. Some clients might insist the value is in the minute
interactions, and perhaps it is. Others might be fine with higher
level stuff. Still others might want a mix. It's up to you to figure
out. Having said that, Cucumber should still have opinions, in my
opinion, about the best way to make it easy to strike that balance.
This brings me to DRY, and helper methods. I think many people believe
that a step definition has the same responsibilities and attributes as
a method or function; that it is "a method with a weird name". This is
a mistake. Step defs have one major responsibility: to map the
language of your domain to your language of implementation. This does
not and can not happen anywhere else. (Currently, at least.) The
responsibility of methods (or functions, or whatever), on the other
hand, is to group conceptually related blocks of code. This is a
subtle but crucial difference--I think the one that trips people up.
It is possible, of course, to include code in your step defs that
manipulates your application, but that is an implementation detail
that makes it easy to get started. It is not *why* step defs exist.
This is why having a step def call a helper method is DRY. DRY isn't
about mechanical duplication of bytes, it is about duplication of
concepts and responsibilities. Step defs and helper methods have two
distinct responsibilities and embody two different concepts, which is
why using both isn't a violation of the DRY principle.
To repeat: steps aren't methods. They are mappers. They're *almost*
named functions, and this is what causes confusion, but Cucumber isn't
nearly close enough to proving Greenspun's 10th Rule [0] to start
treating step definitions as first-class functions in their own right.
HTH,
Mike
[0] http://en.wikipedia.org/wiki/Greenspun's_Tenth_Rule
I've not looked at the ramifications of a "macro" concept here, but I
agree with the rest for readability, and ease of use by people who don't
consider themselves programmers (and some programmers, too).
>> What I have in mind could be implemented through some kind of pre-
>> processing of the .feature file. If I have step definitions that
>> consist purely of other steps (as I often do), I would like the option
>> to mark those as "macros". Thus, when pre-processing:
>>
>> Given ABC
>> Then DEF
>>
>> those macros would get expanded to the full low-level steps before
>> being evaluated. I think this would greatly mitigate the "hard to
>> understand" and "difficult to debug" issues, while still making it
>> possible to write DRYer features.
I suspect that it would be possible to maintain the text of the lower
level sub-steps without a macro concept, but I've not looked at the
current cucumber implementation. The readability of nested steps seems
to be the one place where Fitnesse/Slim surpasses Cucumber, IMO.
Mike, I don't think I understand the point you're trying to make.
Gherkin is just the Given/When/Then/And/But, is it not? Or that, plus
the ability to call a step that matches via a regular expression. Why
should a user who has become comfortable with the steps created via
regular expressions have to drop down to the reading implementing
computer language just to understand something like the name of a field
has changed and the underlying step definition can't find a place for
the specified input?
I fear that cucumber is quickly becoming something that doesn't fulfill
the use I had for it. It seems to be headed toward the programmer
toolspace, rather than also being accessible to testers and business
analysts.
- George
--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------
While I might argue that writing steps in one way is a bad idea, I
think a well-written patch to Cucumber that implements the ideas
people are talking about (printing out the nested step defs) would be
a fine edition to the tool. But no one who wants that to happen has,
so far as I know, submitted a patch for it.
They don't need to. There's nothing that prevents anyone from writing
purely imperative scenarios using the fine-grained steps that ship
with one library or another, (or using a library of them created by a
developer) but the second you start making your own steps--including
nesting them--you're not writing Gherkin, you're writing Ruby, and I'm
of the opinion that that means you should start actually writing Ruby
(and learning a bit about it if need be) rather than acting like
you're not. Trying to hide the fact from people that they're dealing
with a full-blown programming language is, in my opinion, a losing
proposition.
>
> I fear that cucumber is quickly becoming something that doesn't fulfill the
> use I had for it. It seems to be headed toward the programmer toolspace,
> rather than also being accessible to testers and business analysts.
>
I think there are two camps here. One is the camp that sees the
features as belonging to the customer (or the testers or BAs,
what-have-you), and the step defs as belonging to the devs, while the
other camp sees both belonging primarily to the testers. I very
obviously fall in the former camp. There's no reason I can think of
that Cucumber can't support both workflows (even if I think the other
camp is wrong), but, again, no one in the BAs all the way down camp is
submitting any patches to support their preferred style of workflow.
Mike
> - George
>
> --
>
> ----------------------------------------------------------------------
> * George Dinwiddie * http://blog.gdinwiddie.com
> Software Development http://www.idiacomputing.com
> Consultant and Coach http://www.agilemaryland.org
> ----------------------------------------------------------------------
>
On 11/19/10 7:06 PM, Mike Sassak wrote:
> On Fri, Nov 19, 2010 at 5:30 PM, George Dinwiddie
> <li...@idiacomputing.com> wrote:
>> Alas, poor Cucumber, I knew him well.
>
> While I might argue that writing steps in one way is a bad idea, I
> think a well-written patch to Cucumber that implements the ideas
> people are talking about (printing out the nested step defs) would be
> a fine edition to the tool. But no one who wants that to happen has,
> so far as I know, submitted a patch for it.
For my part, I've been too busy to even document the way of working and
the issue, much less to dig into the code. My examples of cucumber are
a little out of date at the moment.
- George
--
Dec. 14 - Agile Richmond in Glen Allen, VA
http://georgedinwiddie.eventbrite.com/
If you reach mid-December and haven't created that patch, but want some
help looking at it, then please contact me. I won't have time before then.
During my recent work to implement a pure java cucumber I have
(almost) come up with the long sought new internal model and API for
the next major version.
I recommend you wait until that is ported back to the ruby code.
Aslak
There's been quite a bit of discussion about this before. A lot of us feel that nesting steps like this is a bit of an anti-pattern. Search the group for posts by Andrew Premdas and you'll get the picture.
This isn't obviously a great reason, but I also suspect this would be pretty awkward to build, and right now the internals of Cucumber are gradually being cleaned up. Until that's done it's hard for us to really even think about building this kind of thing.
cheers,
Matt
http://blog.mattwynne.net
For me, it "communication."
On 11/22/10 11:33 AM, aslak hellesoy wrote:For me, it "communication."
> Question to the group: What benefits do you see in invoking steps
over
> invoking methods?
>
Expediency.
I have heard "expediency" used as an argument for copying and pasting
code too, and this sounds a little similar.
--
Dec. 14 - Agile Richmond in Glen Allen, VA
http://georgedinwiddie.eventbrite.com/
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------
--
Nested steps show the decomposition of higher level steps into more
primitive ones. This helps communicate with different people, and helps
some people understand the higher level constructs from the more
concrete building blocks.
The /optional/ display of the nestedness in the output is helpful for
communication, particularly when a test fails.
- George
> I use nested steps. Though, I often don't have the need for the sub-
> steps to appear in the output.
>
> I have found that I often create a step that collects several
> variations of different steps. The collector step will usually
> implements a table and can be called directly.
>
> The benefit of having this collector step is that my steps are more
> clear, as their are step definitions tailored to each variation, while
> the code remains DRY.
>
> * Any operations common to the family of steps
> ** Validation of the object
> ** Defaults can be applied to all sub-steps
> ** Common operations within all steps
>
> A trivial example: https://gist.github.com/710405
What I don't understand in this example, is why you see it to be an advantage to implement the re-usable behaviour in a step, rather than a method?
Surely it would be just as clear, and I think, more maintainable, to extract a helper method called #create_events and have all three step definitions call that?
Here's my refactoring of your example:
https://gist.github.com/gists/711496
> On Nov 22, 8:33 am, aslak hellesoy <aslak.helle...@gmail.com> wrote:
>> On Sun, Nov 21, 2010 at 8:54 PM, byrnejb <byrn...@harte-lyne.ca> wrote:
>>> On Nov 19, 4:40 am, aslak hellesoy <aslak.helle...@gmail.com> wrote:
>>
>>>> Question to the group: What benefits do you see in invoking steps over
>>>> invoking methods?
>>
>>> Expediency.
>>
>> I have heard "expediency" used as an argument for copying and pasting code
>> too, and this sounds a little similar.
>>
>>
>>
>>
>>
>>
>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Cukes" group.
>>> To post to this group, send email to cu...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> cukes+un...@googlegroups.com <cukes%2Bunsu...@googlegroups.com>.
>>> For more options, visit this group at
>>> http://groups.google.com/group/cukes?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
>
cheers,
Matt
ma...@mattwynne.net
07974 430184
> On 11/22/10 1:36 PM, aslak hellesoy wrote:
>>
>>
>> On Mon, Nov 22, 2010 at 6:15 PM, George Dinwiddie
>> <li...@idiacomputing.com <mailto:li...@idiacomputing.com>> wrote:
>>
>> On 11/22/10 11:33 AM, aslak hellesoy wrote:
>>
>> > Question to the group: What benefits do you see in invoking steps
>> over
>> > invoking methods?
>> >
>>
>> Expediency.
>>
>>
>> I have heard "expediency" used as an argument for copying and
>> pasting
>> code too, and this sounds a little similar.
>>
>>
>> For me, it "communication."
>>
>>
>> Are you saying that nested steps helps achieve better communication?
>> -And more so if the nestedness is displayed in the output?
>
> Nested steps show the decomposition of higher level steps into more primitive ones. This helps communicate with different people, and helps some people understand the higher level constructs from the more concrete building blocks.
>
> The /optional/ display of the nestedness in the output is helpful for communication, particularly when a test fails.
>
> - George
I really value your perspective and contribution to this conversation George. I feel like as long as Cucumber supports nested steps, I think it should be possible to show the nesting in the output. However I am starting to think that we've made a mistake in supporting this feature at all, because it's encouraging people to write what is ultimately, harder-to-maintain code. As Dale Emery says: test automation *is* software development. Step Definitions are not methods, and Cucumber is never going to be as good as Ruby at managing and debugging call stacks. The idea of letting people who don't feel comfortable readying and writing Ruby methods loose in the step definition layer worries me - I'd prefer to see them pairing with developers who are confident enough to keep the code as lean as possible.
In code, we talk about the refactoring operation "inline method" where the method doesn't do anything other than call another method. I think we need to start encouraging people to "inline step definition" so that these macro steps contain less indirection and complexity. Obviously what you trade off here is the maintainability of the codebase vs the readability and trust with less technical members of the team. I guess it's up to each of us to find our own balance point.
+1
What are we going to do about it?
On 11/24/10 9:47 AM, Matt Wynne wrote:
> I really value your perspective and contribution to this conversation
> George. I feel like as long as Cucumber supports nested steps, I
> think it should be possible to show the nesting in the output.
> However I am starting to think that we've made a mistake in
> supporting this feature at all, because it's encouraging people to
> write what is ultimately, harder-to-maintain code.
Harder to maintain by whom?
> As Dale Emery
> says: test automation *is* software development. Step Definitions are
> not methods, and Cucumber is never going to be as good as Ruby at
> managing and debugging call stacks.
Ask Dale, but I don't think he's suggesting we should drop back to
programming languages. Step definitions /are/ programming, but they're
in the language of the business and of the abstractions the business
understands.
> The idea of letting people who
> don't feel comfortable readying and writing Ruby methods loose in the
> step definition layer worries me - I'd prefer to see them pairing
> with developers who are confident enough to keep the code as lean as
> possible.
If I'm going to abandon the aspect of readability for the business, then
why should I use cucumber at all? I can as easily write acceptance
tests in rspec.
> In code, we talk about the refactoring operation "inline method"
> where the method doesn't do anything other than call another method.
> I think we need to start encouraging people to "inline step
> definition" so that these macro steps contain less indirection and
> complexity. Obviously what you trade off here is the maintainability
> of the codebase vs the readability and trust with less technical
> members of the team. I guess it's up to each of us to find our own
> balance point.
In the past year, I've seen cucumber look more like code and be more
tuned to programmers. I think this is at the expense of the business
stakeholders and the testers. I also think it's at the expense of
cucumber, as I think it's abandoning the niche where it's most valuable.
As a programmer, I don't need a natural-language focused test runner.
Matt,Harder to maintain by whom?
On 11/24/10 9:47 AM, Matt Wynne wrote:
I really value your perspective and contribution to this conversation
George. I feel like as long as Cucumber supports nested steps, I
think it should be possible to show the nesting in the output.
However I am starting to think that we've made a mistake in
supporting this feature at all, because it's encouraging people to
write what is ultimately, harder-to-maintain code.
Ask Dale, but I don't think he's suggesting we should drop back to programming languages. Step definitions /are/ programming, but they're in the language of the business and of the abstractions the business understands.
As Dale Emery
says: test automation *is* software development. Step Definitions are
not methods, and Cucumber is never going to be as good as Ruby at
managing and debugging call stacks.
If I'm going to abandon the aspect of readability for the business, then why should I use cucumber at all? I can as easily write acceptance tests in rspec.The idea of letting people who
don't feel comfortable readying and writing Ruby methods loose in the
step definition layer worries me - I'd prefer to see them pairing
with developers who are confident enough to keep the code as lean as
possible.
In the past year, I've seen cucumber look more like code and be more tuned to programmers. I think this is at the expense of the business stakeholders and the testers. I also think it's at the expense of cucumber, as I think it's abandoning the niche where it's most valuable. As a programmer, I don't need a natural-language focused test runner.In code, we talk about the refactoring operation "inline method"
where the method doesn't do anything other than call another method.
I think we need to start encouraging people to "inline step
definition" so that these macro steps contain less indirection and
complexity. Obviously what you trade off here is the maintainability
of the codebase vs the readability and trust with less technical
members of the team. I guess it's up to each of us to find our own
balance point.
- George
--
Dec. 14 - Agile Richmond in Glen Allen, VA
http://georgedinwiddie.eventbrite.com/
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------
--
--
OK, I give up. I don't think you're acknowledging my point that the
business needs to have an understanding that often goes deeper than the
feature description.
I will say that if cucumber becomes just another programmer oriented
tool, I will likely abandon it as I don't think it will meet the needs
that I perceive for my clients.
- George
On 11/24/10 6:03 PM, Andrew Premdas wrote:
>
>
> On 24 November 2010 20:16, George Dinwiddie <li...@idiacomputing.com
--
Andrew,
OK, I give up. I don't think you're acknowledging my point that the business needs to have an understanding that often goes deeper than the feature description.
I will say that if cucumber becomes just another programmer oriented tool, I will likely abandon it as I don't think it will meet the needs that I perceive for my clients.
On 11/25/10 11:21 AM, aslak hellesoy wrote:
> (And this would work at arbitrary levels of nesting)
>
> It's a technique I will not use my self
> It's a technique I will warn against in the documentation
> It's just a long rope you can do whatever you want with
> I understand that some people will want it and others will shun it.
> That's fine with me.
>
> There will be a command line switch to turn it on: --expand-steps
>
> Mmmkay?
We'll see when we get to play with it. I'm hoping to develop some
examples that illustrate the method of working that I've seen be useful.
- George
--