Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reusing Cucumber-JVM step definitions in other projects

How can I reuse Cucumber-JVM Step Definitions in other projects to test some typical web actions. The point is that I've created some java project just with Step Definition Implementations of the typical scenario actions like:

When I follow the link "*some_link*"
Then I should see following content "*some_content*" on page

And I want to reuse these definitions in other projects (include in classpath), just to write their own simple scenarios. But when I run the scenario (as JUnit test), Cucumber cant find Step Definitions. And when I try to extend Step Definitions class it gives me an error, that I can't extent Step Definition class. So, is it possible to reuse Step Definitions and if so than how?

like image 900
kazakovs Avatar asked Oct 12 '12 21:10

kazakovs


1 Answers

Well, I've found solution. It appears quite easy.

There is annotation @CucumberOptions which has parameter "glue". Pointing with this parameter to the base package that has the step definitions forces Cucumber to search in that base package. The test runner will look like:

@RunWith(Cucumber.class)
@CucumberOptions(glue = { "com.example.stepdefspackage" })
public class Run{
}
like image 188
kazakovs Avatar answered Sep 18 '22 22:09

kazakovs