[Gherkin] Generating UML Graph Sequence Diagrams from Gherkin Scenarios

92 views
Skip to first unread message

chris young

unread,
Nov 24, 2009, 4:13:53 PM11/24/09
to Cukes, chris...@bbc.co.uk
Gherkin is working a treat for us on a project at the BBC. Previously
we had produced a lot of UML Sequence Diagrams which whilst they have
their merits have been

overtaken by Gherkin Scenarios which are a lot quicker to write,
refactor and parametrize with example data.

One thing we've lost in moving from the UML Sequence Diagrams to the
Gherkin Scenarios is the visual and spatial qualities of the diagrams.

To regain this I'm looking at how we could generate UML Sequence
Diagrams from our Gherkin Scenarios, the figure below shows the sort
of mapping between the two that I'm thinking of:

http://www.twitpic.com/qshm0

What I'd like to do is translate the Gherkin into UML Graph (http://
www.umlgraph.org/ ) scripts (More specifically Mykhaylo Sorochan's DSL
that sits on top of UML Graph http://macroexpand.org/doku.php/articles:uml-sequence-diagram-dsl-txl:start
)

Has anyone out there looked at doing anything like this and if so,
what are your thoughts?

I figure the stand along Gherkin parser would be a good place to
start...

Cheers

Chris

aslak hellesoy

unread,
Nov 24, 2009, 6:28:31 PM11/24/09
to cu...@googlegroups.com, chris...@bbc.co.uk
Great idea! It's easy to hook into Gherkin. Check out these files:

http://github.com/aslakhellesoy/gherkin/blob/master/bin/gherkin
http://github.com/aslakhellesoy/gherkin/blob/master/lib/gherkin/tools/pretty_printer.rb
(a sample listener)

To build/install:

There are no releases yet, so the process is a little manual.
First, you need ragel installed. Then:

OS X/Linux:
rake ragel install

JRuby:
rake ragel compile install

To run the pretty printer:

gherkin path/to/my.feature

If you open source your gherkin2uml - please add it to
http://wiki.github.com/aslakhellesoy/cucumber/related-tools and send
us an update.
Ideally the gherkin CLI would accept a --listener argument (e.g.
--listener Gherkin::Uml), so feel free to fork gherkin and hack on
that.

Aslak

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

chris young

unread,
Nov 24, 2009, 7:04:52 PM11/24/09
to Cukes
Many thanks for that Aslak, those pointers are a great help.

I've set aside some time this weekend to work on this and will be sure
to share the results.

This will be the first time I've looked at Ruby so should be a lot of
fun.

Cheers and thanks again.

Chris

Jean-Michel

unread,
Nov 25, 2009, 8:31:09 AM11/25/09
to Cukes
Hi Aslak & Chris,

On Nov 25, 1:04 am, chris young <chrisyoung....@gmail.com> wrote:
> Many thanks for that Aslak, those pointers are a great help.
>
> This will be the first time I've looked at Ruby so should be a lot of
> fun.

Chris, I would like to contribute to your project. For a quick
prototype, we could use http://github.com/EmmanuelOga/websequencediagrams
which generates sequence diagrams on http://www.websequencediagrams.com/
using a super simple DSL: Alice->Bob: Authentication Request

You can contact me at http://github.com/garnierjm/

When refactoring legacy code - with obscure method names and complex
chain of method calls - I tend to prepare my work with a sequence
diagram. In some cases, it's a very good ROI as reading again and
again the same dirty code in order to understand who is doing what is
very time consuming.

A picture is worth a thousand words. A diagram such as
http://www.websequencediagrams.com/?lz=TWFudWFsV2ViRG9uYXRpb25TdGVwNC0-AAcIQ29udHJvbGxlcjogY29uZmlybQoAChIAJgoAHQkhAB4JABEMdXBkYXRlX2F0dHJpYnV0ZSg6AE4HZWQsIHRydWUpACIVABwJPQBLC0Fic3RyYWN0AHEKcmVjZWl2ZXJfbmVlZHNfAGcGIQoAGRAAJxRhZnRlcl9zYXZlAIEcCQBGCAAtE0VsZW1lbnQ6AIFIB2Rlcml2ZWQAgU0KcyEKABwHACMJT2JzZXJ2ZXIAXwwAHQgAFAgtPlByb2plY3QAgiAJAEYUAB0HAAkkABkTc2F2ZV93aXRob3V0X3ZhbGlkAINyBQBDFGJlZm9yZQCCEAUAgzEIcHJvZ3Jlc3NfcGVyY2VudGFnZQB9EwATEyA9&s=modern-blue
communicates very well to developers that codes smells like an old
camembert (very very bad).

JM

Reply all
Reply to author
Forward
0 new messages