This is an example Cucumber-JVM project.
- Uses Java 8 lambda step definitions
- Packages tests into executable jar file
- Uses Guice dependency injection
Using executable jar file:
mvn clean package
java -jar target/cucumber-jvm-java-example.jar --plugin pretty --plugin html:cucumber/html --plugin json:cucumber/json/cucumber.json --glue steps classpath:features --tags ~@Wip
Using Maven exec plugin:
mvn exec:java -Dcucumber.options="--plugin pretty --plugin html:cucumber/html --plugin json:cucumber/json/cucumber.json --glue steps classpath:features --tags ~@Wip --tags @ExampleFeature"
Using JUnit test runner:
mvn test -Dtest=ExampleFeatureTest
Using Docker:
Build Docker image (see build-docker-image.sh
)
IMAGE_NAME=jecklgamis/cucumber-jvm-java-example
IMAGE_TAG=latest
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
Run Docker image (see run-all-tests-using-docker.sh
)
IMAGE_NAME=jecklgamis/cucumber-jvm-java-example
IMAGE_TAG=latest
JAVA_OPTS=${JAVA_OPTS:-""}
ARGS=${ARGS:-"--plugin pretty --plugin html:cucumber/html --plugin json:cucumber/json/cucumber.json --glue steps classpath:features --tags @ExampleFeature"}
docker run -e "JAVA_OPTS=${JAVA_OPTS}" -e "ARGS=${ARGS}" ${IMAGE_NAME}:${IMAGE_TAG}
In Intellij, you can also run the scenario directly from the feature file. Ensure you have the Cucumber Java plugin installed.