-
Notifications
You must be signed in to change notification settings - Fork 5
EasyCukes REST project creation
Since EasyCukes relies on Maven, we'll recommend for your project using EasyCukes to use that tool too. We'll skip that part of Maven project creation in our documentation, assuming you know how to invoke an archetype, or create manually a Maven project from scratch. If that's not the case, please have a look at Maven documentation for more information ;)
For using EasyCukes in order to test REST services, you won't need many things actually:
#POM configuration Actually, the only thing you'll need there is to add the EasyCukes dependency:
<dependency>
<groupId>com.worldline.easycukes</groupId>
<artifactId>easycukes-rest</artifactId>
<version>1.2.0</version>
</dependency>#JUnit Runner In order for your tests to be executed by Maven through JUnit, we'll just need to implement a small Runner in your project, in which you'll be able to specify some Cucumber options:
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
/**
* This {@link RunCukesTest} class simply allows to specify all the options to
* set for Cucumber in order to run it with JUnit.
*
* @author aneveux
* @version 1.0
*/
@RunWith(Cucumber.class)
@CucumberOptions(features = { "classpath:features/" }, format = { "json",
"html:target/cucumber-html-report",
"json:target/cucumber-json-report.json" }, tags = { "~@wip" }, glue = { "com.worldline.easycukes" })
public class RunCukesTest {
}What's important here is the glue parameter, which allows to specify that your cucumber tests will actually use EasyCukes. Then, the features parameter allows you to specify the folder in which the features are created. In this example, it requires the features to be a in a features folder, located in src/test/resources for example.
#Features Guess what? That's all!
The only remaining thing for you is to write your features files in src/test/resources/features. It's pure Cucumber, except that you can use our predefined steps for easing the tests of REST APIs. Check out our documentation related to that ;)