[JVM] Cucumber -- sharing glue code amongst projects...

384 views
Skip to first unread message

rickkar

unread,
Sep 17, 2013, 9:37:53 AM9/17/13
to cu...@googlegroups.com
thanks in advance... 

1) given separate projects, is it possible to see examples/pointers for sharing glue code, i.e., calling one project's glue code from another project?

please let me know -- i appreciate your help!

Saif

unread,
Sep 17, 2013, 11:52:22 AM9/17/13
to cu...@googlegroups.com
Look into glue option. http://stackoverflow.com/questions/12867492/cucumber-jvm-step-definition-java

Also, make sure you have project you are referring to in your classpath

Paolo Ambrosio

unread,
Sep 17, 2013, 3:15:34 PM9/17/13
to cu...@googlegroups.com
On Tue, Sep 17, 2013 at 2:37 PM, rickkar <rmka...@gmail.com> wrote:

> thanks in advance...
>
> 1) given separate projects, is it possible to see examples/pointers for
> sharing glue code, i.e., calling one project's glue code from another
> project?

The glue code is searched in the classpath, so technically you should
be able to import and use a jar with glue code.

Not sure if it's your case, but usually this is a test smell. If
different projects use the same set of steps, it might mean that they
are too generic and you are using an imperative style.

A bad scenario example with reusable steps (as they target the browser
domain and not the application domain):

Given I go to the home page
And I click "sign in"
And I fill "username" with "bob"
And I fill "password" with "bobspass"
When I click "signin"
Then I should be redirected to the home page
And I should see "Hello, Bob"

A better example would be something like:

Given a user exists
When he signs in
Then he should be redirected to the home page
And he should be greeted

This is called "pushing how down the stack", as Matt explained in his talk here:

http://skillsmatter.com/podcast/java-jee/why-your-step-definitions-should-be-one-liners-and-other-pro-tips

I think it would be much better to write a helper library of reusable
code to plug into step definitions, instead of a library of reusable
steps that would probably make your scenarios unreadable.


Paolo
Reply all
Reply to author
Forward
0 new messages