SOS - I want to extend Gherkin keywords

612 views
Skip to first unread message

Amir Hossein Ebrahimi

unread,
May 13, 2011, 4:37:01 PM5/13/11
to SpecFlow
Hi all,
I am a new user to the Spec Flow. I want to add some items to the list
of keywords which is already used in the Gherkin environment. So for
example along side "Scenario, Given, Then, ...", it also recognizes
"X, Y" and brings these new items in the intellisence in the feature
files.
In the source files of SpecFlow I found "Language.xml" which contained
a list of all 12 keywords in the English language version of the
environment but I could not find this file on the system when SpecFlow
is installed.
Could any one help me?

Amir

Gáspár Nagy

unread,
May 14, 2011, 2:22:28 AM5/14/11
to SpecFlow
it is not possible to change the keywords in SpecFlow, there is a
special parser generated for each language within the gherkin
project. the xml file you've mentioned is just an extract from the
compiled parser.

On May 13, 10:37 pm, Amir Hossein Ebrahimi

Amir Hossein Ebrahimi

unread,
May 14, 2011, 5:01:18 AM5/14/11
to SpecFlow
Hi,
I am doing a research in which I need to extend the BDD keywords (I
don't want to remove any of the existing words but I want to add to
these words). In doing so I also want to be able to use the
intelisence of the SpecFlow, and add these extended keywords to the 12
keywords Ghurkin already has. Do you think there is any way to do
this?

Amir

larry smithmier

unread,
May 15, 2011, 9:25:52 AM5/15/11
to SpecFlow
I believe what Gáspár actually meant is that it is non-trivial
(multiple weeks of work) to change the keywords in SpecFlow. The
source is available at https://github.com/techtalk/SpecFlow and you
can extend it by changing the code. The first thing to do is to dig
into the code and understand what it is doing. I would start by going
through the tests, specifically the ParserTests. You need to
understand what it is currently doing before you can extend it at such
a fundamental level. I am just a lurker, not a SpecFlow developer, so
my knowledge of the source is probably at or below your level. Do not
be discouraged! But also, don't expect someone to do the work for
you. Dig through the code, and if you run into problems, ask specific
questions with enough background information on things you tried to
show that you have been working on it yourself.

On May 14, 5:01 am, Amir Hossein Ebrahimi

Jonas Bandi

unread,
May 15, 2011, 9:33:41 AM5/15/11
to spec...@googlegroups.com
Actually the issue is even a bit more complicated.

The keywords are defined by the Gherkin project
(https://github.com/cucumber/gherkin).
Gherkin defines an established language that is used in a lot of tools.
It is currently not the goal nor in the scope of the SpecFlow project
to define or change that language.

So while it is certainly possible to change the keywords, it is a lot
of work and you will probably be pretty much on your own.
A possible way is to go to the Gherkin project and introduce your
suggestions there. Any changes in Gherkin will be adapted by SpecFlow.

Regards
jonas

--
mail: jonas...@gmail.com
web: www.jonasbandi.net
blog: blog.jonasbandi.net
twitter: twitter.com/jbandi

larry smithmier

unread,
May 15, 2011, 2:55:51 PM5/15/11
to SpecFlow
Yes, Jonas is certainly correct. I wouldn't expect your changes to be
adopted in the main code branch any time soon without getting the
language changes adopted by the Gherkin project. I remember an earlier
discussion that emphasized the relationship between Gherkin and
SpecFlow but I can't find it now.

On May 15, 9:33 am, Jonas Bandi <jonas.ba...@gmail.com> wrote:
> Actually the issue is even a bit more complicated.
>
> The keywords are defined by the Gherkin project
> (https://github.com/cucumber/gherkin).
> Gherkin defines an established language that is used in a lot of tools.
> It is currently not the goal nor in the scope of the SpecFlow project
> to define or change that language.
>
> So while it is certainly possible to change the keywords, it is a lot
> of work and you will probably be pretty much on your own.
> A possible way is to go to the Gherkin project and introduce your
> suggestions there. Any changes in Gherkin will be adapted by SpecFlow.
>
> Regards
> jonas
>
>
>
>
>
>
>
>
>
> On Sun, May 15, 2011 at 3:25 PM, larry smithmier <la...@smithmier.com> wrote:
> > I believe what Gáspár actually meant is that it is non-trivial
> > (multiple weeks of work) to change the keywords in SpecFlow.  The
> > source is available athttps://github.com/techtalk/SpecFlowand you
> mail: jonas.ba...@gmail.com

Gáspár Nagy

unread,
May 16, 2011, 4:03:56 AM5/16/11
to SpecFlow
Jonas' comments are proper.

However, if I've understood Amir well, he does not want to include
this into the live product, but just need it for an (Univ?) research.

If this is the case, you can do the following:
- fork the Gherkin project (https://github.com/cucumber/gherkin) and
ensure you can build it
- update the Gherkin language specification (https://github.com/
cucumber/gherkin/blob/master/spec/gherkin/i18n_spec.rb) with the
additional necessary keywords
- build Gherkin with the modified specs, take the generated .NET
assembly (Gherkin-x.x.x.dll)
- fork the SpecFlow project and import the updated Gherkin parser
based on the instructions here: https://github.com/techtalk/SpecFlow/wiki/Updating-the-Gherkin-Parser
Reply all
Reply to author
Forward
0 new messages