[Cucumber-Java8] How to reuse step defs?

458 views
Skip to first unread message

Rafael Naufal

unread,
Feb 12, 2016, 10:03:58 AM2/12/16
to Cukes
Hi folks,

I'm using cucumber-java8 to create my step definitions (using lambda expressions defined in the constructor), as suggested in the following link: https://cucumber.io/docs/reference/jvm#java (lambda expressions - Java 8).

There are some step definition classes that share the same steps defined as lambda expressions and as such I'm having the following problem:

cucumber.runtime.CucumberException: cucumber.runtime.DuplicateStepDefinitionException: Duplicate step definitions

When I try to run them separately, it works well as expected. When I try to run my all my tests suite using Gradle (using the -g parameter to specify a list of step definition classes) , I got the error above.

So, is there a possibility to reuse step definitions using cucumber-java8 and lambda expressions?

Kind regards, 

Rafael

Thomas Sundberg

unread,
Feb 15, 2016, 3:51:53 AM2/15/16
to cu...@googlegroups.com
Assuming that the implementation for two steps is equal, what happened
when you removed one? Was the other one picked up?

I haven't tried this myself, but given that the non Java 8
implementation behaves like that I would expect the remaining step
being picked up in a Java 8 lambda implementation. If this is true,
you are able to reuse step definitions.

Give it a spin and tell us about your findings.

Cheers
Thomas



> Kind regards,
>
> Rafael
>
> --
> Posting rules: http://cukes.info/posting-rules.html
> ---
> 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/d/optout.



--
Thomas Sundberg
M. Sc. in Computer Science

Mobile: +46 70 767 33 15
Blog: http://thomassundberg.wordpress.com/
Twitter: @thomassundberg

Better software through faster feedback
Reply all
Reply to author
Forward
0 new messages