문제

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?

도움이 되었습니까?

해결책

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{
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top