Cucumber JVM is Java implementation of Cucumber BDD.
Integrating into the Project
The installation using maven is super simple, just add the dependency and you are ready to go. Make sure you add both command line interface (cucumber-core) and the IDE interface (cucumber-junit)
I was using Intellij and add Intellij Cucumber plugin, to make the navigations easier.
One thing i liked very much is the ability to add custom annotations to the feature. You can add a custom annotation and can create Before and After hook for them.
In the step definitions file.
Integrating with Spring
For Spring integration you need to add one more component of the cucumber-jvm (cucumber-spring)
It is advisable to have a test runner class which can run all the feature files in one go especially when you are runnning in the CI.
The structure of the test runner class will be :
Make sure to place all the feature files in the same package as of this Runner class. Or you can specify the path using the cucumber options, like this.
If you are placing all the step definition in other package you can add that to the annotation using glue attribute.
This will look up for cucumber.xml file in the classpath. This xml file can hold all the bean definitions. My cucumber.xml was super simple.
The step defnitions can lie in a different package and make sure you use glue attribute to wire them in the Runner class.
Integrating with Spring Transactions
One last thing that i wanted to do is to hook up Spring transactions. So all the data created by the features have to be removed after the test completes. So you can write independent tests without bothering about the data.
You can use 'txn' annotation that comes with Cucumber-JVM. All you need to do is to wire up that package along with your adapter class.
@txn Scenario: Some scenario to test