Question

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?

Était-ce utile?

La solution

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{
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top