[JVM] Gherkin parser support for tag name value pairs?

170 views
Skip to first unread message

Grant Freder

unread,
Jul 12, 2013, 2:50:03 PM7/12/13
to cu...@googlegroups.com
Hello,

I am using your Gherkin parser to read .feature files and output the result to json (which will then be fed into my application). It has been working fairly well, but I ran into an issue when attempting to deal with tags.
Because tags are used to provide additional information about the particular scenario or feature and are useful when filtering/searching through scenarios and features, the more flexibility to include information the better. 
 
In my experience and those around me who have much more expertise than me with BDD, the .feature files have tags formatted this way…

@tagName tagValue
placed either before the scenario or before the feature.


@author Grant
Feature: Testing assorted things 
    As a user of this computer 
    I want to perform basic functionalities of Windows 
    So that I can perform more advanced tasks.
 
or
 
@type random
Scenario: WMP 
  Given a windows media player
  When I double click on a song
  Then I should hear that song playing

When using your parser, it handles tags in the same locations, but it appears like it only can handle tags formatted like...
@tagName
                       ^ Note the absence of the tagValue.
 
When I put a tagValue like...
@author Grant
Feature: Testing assorted things 
    As a user of this computer 
 
it comes up with

gherkin.lexer.LexingError: Lexing error on line 1: '@author Grant

 
 
as your wiki would indicate... Gherkin has been fed some input which it cannot recognize at all
 
Am I formatting something incorrectly?  if so, please let me know how to fix it.  if not...
Is there a way for me to configure the parser to handle tag name value pairs?  if so, please let me know how. if not...
Might there be a possibility to include this capability?   if so, that would greatly appreciated J:)
 
I am using the gherkin-2.12.0.jar
 
Sincerely,
Grant Freder
 

aslak hellesoy

unread,
Jul 12, 2013, 6:13:44 PM7/12/13
to Cucumber Users
On Fri, Jul 12, 2013 at 1:50 PM, Grant Freder <gfr...@gmail.com> wrote:
Hello,

I am using your Gherkin parser to read .feature files and output the result to json (which will then be fed into my application). It has been working fairly well, but I ran into an issue when attempting to deal with tags.
Because tags are used to provide additional information about the particular scenario or feature and are useful when filtering/searching through scenarios and features, the more flexibility to include information the better. 
 
In my experience and those around me who have much more expertise than me with BDD, the .feature files have tags formatted this way…

@tagName tagValue

That's incorrect. Gherkin tags are simple labels without values beyond themselves. They work in the same way as they do on countless web sites - a concept popularised by Delicious and Flickr.

I think you're mixing them up with Javadoc tags.

Aslak
 
placed either before the scenario or before the feature.


@author Grant
Feature: Testing assorted things 
    As a user of this computer 
    I want to perform basic functionalities of Windows 
    So that I can perform more advanced tasks.
 
or
 
@type random
Scenario: WMP 
  Given a windows media player
  When I double click on a song
  Then I should hear that song playing

When using your parser, it handles tags in the same locations, but it appears like it only can handle tags formatted like...
@tagName
                       ^ Note the absence of the tagValue.
 
When I put a tagValue like...
@author Grant
Feature: Testing assorted things 
    As a user of this computer 
 
it comes up with

gherkin.lexer.LexingError: Lexing error on line 1: '@author Grant

 
 
as your wiki would indicate... Gherkin has been fed some input which it cannot recognize at all
 
Am I formatting something incorrectly?  if so, please let me know how to fix it.  if not...
Is there a way for me to configure the parser to handle tag name value pairs?

No.
 
  if so, please let me know how. if not...
Might there be a possibility to include this capability?

No, I don't think that would be a good idea.

Cheers,
Aslak
 
   if so, that would greatly appreciated J:)
 
I am using the gherkin-2.12.0.jar
 
Sincerely,
Grant Freder
 

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
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 https://groups.google.com/d/forum/cukes?hl=en
---
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Grant Freder

unread,
Jul 17, 2013, 12:09:22 PM7/17/13
to cu...@googlegroups.com
Hrm.  That's interesting.  You have a very valid point.  I think I may have misunderstood things.
 
If that is the case though, may you help me understand this then?
 
jbehave, which is a bdd tool, does appear to support @tagName tagValue pairs.
note that they do say that "Meta information is provided as a list of name-value properties"
 
also, a sample from a jbehave's xml output...
<story path="examples/jbehave/table_test.feature"
 
title="As a user of this computer
I want to perform table tests
So that I can tell Garrett"
>
 
<meta>
 
<property keyword="@" name="author" value="Grant" />
 
<property keyword="@" name="number" value="10" />
 
<property keyword="@" name="scenario_title" value="" />
 
</meta>
 
<scenario keyword="Scenario:" title="Testing the table feature">
 
<step outcome="successful">
   Given a colon:
   
<parameter>
   
<parameters>
     
<names>
     
<name>message</name>
     
<name>number</name>
     
</names>
     
<values>
     
<value>hello</value>
note that the meta properties contain tags with names and values
 
And it also appears like jbehave depends on your parser...
 
For now, at least on our end here, we're going to ask our users to transform their tags from
@alm 12       to     @alm.12    or perhaps   @alm_12   to conform with your parser... which shouldn't be a problem.
 
Thank you for helping me understand this concept.
 
Sincerely,
Grant

aslak hellesoy

unread,
Jul 17, 2013, 12:16:06 PM7/17/13
to cu...@googlegroups.com
Please see the mailing list rules, especially 2.
I think you should ask the JBehave devs how    they accomplish name-value tags with Gherkin. It sounds like magic.

Out of curiosity, why do you need name-value pairs?

Aslak
Reply all
Reply to author
Forward
0 new messages