Cuke4Nuke crazy alternate syntax idea

8 views
Skip to first unread message

Shannon

unread,
Nov 25, 2009, 7:31:00 PM11/25/09
to Cukes
Hi,

I've been thinking of alternate syntax ideas for Cuke4Nuke to remove
the duplication in the method name and Regular Expression.

[Given(@"^a person with (\S+) fingers$")]
public void GivenAPersonWithFingers(int numberOfFingers) {}

My idea is to remove the regular expression and use the method name
instead. The above sample could be

public void GivenAPersonWith_numberOfFingers_Fingers(int
numberOfFingers) {}

or

public void given_a_person_with_0numberOfFingers_fingers(int
numberOfFingers) {}
// The above example places a zero infront of the inline argument for
people who like to use underscores in method names
// My initial idea was use @ instead of the zero, but the C# langauge
does not allow @ in the name except at the start.

And when an argument is at the end, you can omit the argument from the
method name. eg

public void GivenAPersonWith(string appendage)

or

public void given_a_person_with(string appendage)

The advantage of using the method names is to remove the duplication
in the regex and method name and to remove the decision as to what to
name the method.
You would want to keep the [Given, When, Then] attributes on the
methods to allow the framework to pick up the methods from the
assembly.

Shannon,

Richard Lawrence

unread,
Nov 25, 2009, 8:36:40 PM11/25/09
to cu...@googlegroups.com
Hi Shannon,

IMO, the regular expressions are one of the biggest strengths of
Cucumber over something like FitNesse's DoFixture, which depends on
method names. I agree that the duplication in C# (and Java) is
unfortunate, but I wouldn't want to lose the regular expressions. The
lamba-based step definition syntax described in the original Cuke4Nuke
thread (and our first source commit) removes this duplication by
removing the need for a method name (see
http://groups.google.com/group/cukes/browse_thread/thread/27674320d7725feb/de37f6b08d551aae?#de37f6b08d551aae).
In my experience with Cuke4Nuke and Cuke4Duke so far, the throwaway
method name is an annoyance, but not enough of one to justify the
tradeoffs inherent in any of the alternative syntaxes proposed so far.
That said, you're welcome to fork Cuke4Nuke and take a stab at the
syntax you suggest. If enough people like it, I'll consider merging it
back into my repo.

Thanks,

Richard
> --
>
> 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.
>
>
>
Reply all
Reply to author
Forward
0 new messages