Cucumber-In-The-Yard (Documentation)

272 views
Skip to first unread message

Franklin Webber

unread,
Oct 14, 2010, 6:41:51 PM10/14/10
to Cukes
aslakhellesoy et al,

I recently finished some preliminary work on an Cucumber YARD
extension. Cukes-in-the-YARD is able to parse features, scenarios,
tags, and step definitions/transforms. Creating searchable
documentation (by feature, tag, scenario, and step) and mapping steps
to step definitions.

Example output, of the trivial example project, can be found here:
http://recursivegames.com/cukes/
Project Home: http://github.com/burtlo/Cucumber-In-The-Yard
Gem information: http://rubygems.org/gems/cucumber-in-the-yard

I initially started out utilizing a very poor custom feature file
parser that I a later replaced with Gherkin. There are more
optimizations and clean up in store for the project.

One feature of the gem performs mapping steps to step definitions. At
the moment, after I have loaded a feature, I look through all the
steps and find a regexp match to a step definition and establish that
link. I feel as though I am being horribly inefficient O(n^2) in this
area and I am also likely re-creating functionality (similar to the
parser) that already exists in Cucumber. I wanted to know if there
were some tactics that any of you have employed with regards to step
to step definition/transform mapping.

Thank you aslakhellesoy and to every contributor to the Cucumber
project.

Cheers,
Frank

Matt Wynne

unread,
Oct 15, 2010, 6:35:24 AM10/15/10
to cu...@googlegroups.com

Frank,

This is a terrific piece of work. Thank you for sharing it with us. I'm sure it will help a lot of people to draw their non-technical team members closer into the cukes. Using YARD is precisely the idea I had for http://relishapp.com before Justin persuaded me we could make it into a web service.

If you want some help parsing step definitions, I've done some refactoring around that code so we can all start to think about using Cucumber as a library for other projects, like yours. There's now a StepDefinitions class which you can use. The behaviour is documented here:

http://github.com/aslakhellesoy/cucumber/blob/master/features/api/list_step_defs_as_json.feature

Maybe that will be of some use? Feel free to submit patches or talk to us on #cucumber if you'd like to see more data in the JSON - we've kept it simple for now but it should be relatively easy to add, for example, the location (file/line) where the step definition is defined.

cheers,
Matt

http://blog.mattwynne.net
http://relishapp.com
+44(0)7974 430184

Richard Lawrence

unread,
Oct 15, 2010, 11:33:23 AM10/15/10
to cu...@googlegroups.com
Matt,

Will this work with non-Ruby step defs (say, at the other end of the
wire protocol)?

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.
>
>

Robert

unread,
Oct 15, 2010, 11:36:52 AM10/15/10
to Cukes
Wow!! Fantastic.

I am relatively new to Cucumber and have recently installed Cuke4Duke
to support our Java environment. Will this also work with step
definitions written in Java? If not, are there any plans or
workarounds to support Java? Wonderful work...I've been looking for
something like this to show our Product Managers.

Matt Wynne

unread,
Oct 15, 2010, 11:52:31 AM10/15/10
to cu...@googlegroups.com

> On Fri, Oct 15, 2010 at 4:35 AM, Matt Wynne <ma...@mattwynne.net> wrote:
>> If you want some help parsing step definitions, I've done some refactoring around that code so we can all start to think about using Cucumber as a library for other projects, like yours. There's now a StepDefinitions class which you can use. The behaviour is documented here:
>>
>> http://github.com/aslakhellesoy/cucumber/blob/master/features/api/list_step_defs_as_json.feature

On 15 Oct 2010, at 16:33, Richard Lawrence wrote:

> Matt,
>
> Will this work with non-Ruby step defs (say, at the other end of the
> wire protocol)?

Not yet. We'll need to implement a new message on the wire protocol that queries for all step definitions, and expose it through a new #step_definitions method on Cucumber::WireSupport::WireLanguage.

RIght now I think you'd probably get a NoMethodError if you tried it.

cheers,
Matt

http://blog.mattwynne.net
+44(0)7974 430184

Franklin Webber

unread,
Oct 15, 2010, 3:51:14 PM10/15/10
to Cukes
It will not work for Java. At the moment I implemented Ruby handlers
for step definitions and step transforms. If YARD had a Java file
parser and object handler I could likely finish one very quickly. It
doesn't, but could.

In November, I'll see if I can spend some of time, while I am creating
some articles/tutorials for yardoc.org, in generating a rudimentary
Java step definition parser. It would be similar to the work that I
did parsing and handling Gherkin files.

In other words, I would love to help deliver this functionality.

Aslak Hellesøy

unread,
Oct 15, 2010, 4:15:15 PM10/15/10
to cu...@googlegroups.com, Cukes

On Oct 15, 2010, at 21:51, Franklin Webber <frankli...@gmail.com> wrote:

> It will not work for Java. At the moment I implemented Ruby handlers
> for step definitions and step transforms. If YARD had a Java file
> parser and object handler I could likely finish one very quickly. It
> doesn't, but could.
>
> In November, I'll see if I can spend some of time, while I am creating
> some articles/tutorials for yardoc.org, in generating a rudimentary
> Java step definition parser.

Don't implement a parser for Java (or any of the 10ish languages supported by Cucumber/Cuke4Duke/Cuke4Nuke.

We'll add native support for this in Cucumber soon.

Aslak

Franklin Webber

unread,
Oct 15, 2010, 4:21:51 PM10/15/10
to Cukes
Matt,

Shortly before finishing the gem I saw relishapp and a few other very
awesome projects moving forward on this front. Needless to say, I am
very impressed with relishapp. The hierarchal view of the features
and scenarios is extremely useful and something that I can get YARD to
accomplish now that I have conquered the notion of YARD's Namespace
Objects.

YARD's Ruby handlers matched step definitions and transforms fairly
effortlessly. Though, I have likely matched without regard to
localization. The issue that I face at the moment is that I attempt
to compare the found steps to the found step definitions and that
operation appears to be laborious. While the trivial example in the
project works well in matching steps to step definitions (even with
constants that have constants) I have not had such luck with all step
definitions in a larger project. The majority of the blame in this
matter falls on me. I need to understand how YARD ensures an object
is loaded and moves items to the back of the line. However, while I
examine this process I was also looking to reduce the complexity that
I generated with this code:

http://github.com/burtlo/Cucumber-In-The-Yard/blob/master/lib/yard/handlers/step_definition_handler.rb

I attempt to "unpack" constants by attempting to find their translated
values and replace them when it comes to comparing them to step
definitions. Perhaps this could be solved by utilizing another means
of handling step definitions (instead of the YARD Ruby method) with
what you have provided.

After unpacking of the step definitions I perform the laborious
comparison that I mentioned earlier:

http://github.com/burtlo/Cucumber-In-The-Yard/blob/master/lib/yard/handlers/cucumber/feature_handler.rb

I also thought that there might be some existing procedure in Cucumber
that might be more effective or efficient.

Lastly, I am thinking that after I match a step to a step definition
that I will want to then try and find the groups and see if any of
those groups match step transforms. This is so I can provide more
detailed information in the documentation which transforms are also
having an effect on steps and step definitions.
> This is a terrific piece of work. Thank you for sharing it with us. I'm sure it will help a lot of people to draw their non-technical team members closer into the cukes. Using YARD is precisely the idea I had forhttp://relishapp.combefore Justin persuaded me we could make it into a web service.
>
> If you want some help parsing step definitions, I've done some refactoring around that code so we can all start to think about using Cucumber as a library for other projects, like yours. There's now a StepDefinitions class which you can use. The behaviour is documented here:
>
> http://github.com/aslakhellesoy/cucumber/blob/master/features/api/lis...

Robert

unread,
Oct 16, 2010, 1:37:57 PM10/16/10
to Cukes
Aslak and Frank,

Anxiously looking forward to its support within Cucumber. You and the
rest of the Cucumber team are amazing! A big thank you for all that
you do to support this fantastic tool.

Regards,
Robert

On Oct 15, 1:15 pm, Aslak Hellesøy <aslak.helle...@gmail.com> wrote:

Franklin Webber

unread,
Oct 28, 2010, 8:41:56 PM10/28/10
to Cukes
Matt et al,

Cucumber-In-The-YARD,http://github.com/burtlo/Cucumber-In-The-Yard,
now matches step transforms to the steps that have be matched to their
step definition (given that all the constants used in them have been
loaded).

Example: http://recursivegames.com/cukes/requirements/step_transformers.html#definition_1-stepdefinition

I ran into that performance nightmare that I worried about where my
large cucumber project (129 features / 524 scenarios) took about 2
hours to complete documentation! After some quick optimizations I got
the process down to 16 minutes. Before I proceed with the next
iteration I wanted to share some thoughts to brainstorm ideas and also
to ensure I am not reproducing work.


I have completed the first two steps:

Step 1. Cache the Step Definitions and Step Transforms instead of
looking in the YARD::Registry each time.

Step 2. Retrieve all Step Definition and Step Transform comparison
values, turn them into regular expressions, and create a hash
structure with the regex as the key and StepDefinition/StepTransform
object as the value.


Here are my thoughts about future optimization:

Step 3. Step Definition and Step Transforms that have been matched are
moved to the top of the list; allowing the next comparison of the step
to benefit.

* Scenario Outlines are very often the same series of steps mapped to
step definitions so this could be further optimized, for very minor
gain, by queuing up the steps in order of the scenario outline.

* Step Transforms are maintained in order of how often they are used
instead of last time they were used. In the current project, and I am
guessing other projects, that certain step transforms are used more
than others and it would be more efficient to maintain them in most
used order. This again would be a minor improvement over simply
bringing the last matched item to the top of the list.


Any suggestions, ideas or comments?

Franklin Webber

unread,
Oct 29, 2010, 3:33:06 PM10/29/10
to Cukes


On Oct 28, 5:41 pm, Franklin Webber <franklin.web...@gmail.com> wrote:
> Here are my thoughts about future optimization:
>
> Step 3. Step Definition and Step Transforms that have been matched are
> moved to the top of the list; allowing the next comparison of the step
> to benefit.
>
> * Scenario Outlines are very often the same series of steps mapped to
> step definitions so this could be further optimized, for very minor
> gain, by queuing up the steps in order of the scenario outline.

Upon further conversion with a co-worker suggested more of a cache
list but I realize that I have not taken into consideration steps
matching multiple step definitions. So this optimization is not idea
if I wanted to share in the documentation the ambiguous step
definitions.

> * Step Transforms are maintained in order of how often they are used
> instead of last time they were used.  In the current project, and I am
> guessing other projects, that certain step transforms are used more
> than others and it would be more efficient to maintain them in most
> used order.  This again would be a minor improvement over simply
> bringing the last matched item to the top of the list.

My large project has 33 Transforms and any benefit here would be
extremely marginal.

DEEPAK KUMAR

unread,
Oct 13, 2017, 6:17:23 AM10/13/17
to Cukes
Thanks guys.

You guys are awsm.

Could you please let me know that now java support is available or not. I am looking to parse java step definition. If yes, please let me the steps to produce document from java step definition files because I am new for ruby.

Thanks in advance.

Looking for your help.

80Vikram

unread,
Oct 23, 2017, 11:36:06 AM10/23/17
to Cukes
Hi Deepak,

Using yard cucumber is quite simple and doesn't need detailed Ruby knowledge.

You can refer to blog https://nileshdk.wordpress.com/2014/03/16/bdd-living-documentation-using-yard-cucumber/

Regards,
Vikram


On Friday, October 13, 2017 at 12:17:23 PM UTC+2, DEEPAK KUMAR wrote:
Thanks guys.

You guys are awsm.rd
Reply all
Reply to author
Forward
0 new messages