acceptance example

For this example, we'll first add the Cucumber modules to our build. I'm adding the spring module as well because we are working wih Spring Boot. At the current date there are a few additional configurations and files we need to add to make Cucumber work with Junit5 and we'll show those in this section

Cucumber JVM Setup

Add the Cucumber modules to the build - in this case we are using Gradle

build.gradle.java
configurations {
    cucumberRuntime {
        extendsFrom testImplementation
    }
}

dependencies {

    ...

// Cucumber
testImplementation group: 'io.cucumber', name: 'cucumber-java', version:  "${cukesVersion}"
testImplementation group: 'io.cucumber', name: 'cucumber-junit-platform-engine', version: "${cukesVersion}"
testImplementation group: 'io.cucumber', name: 'cucumber-spring', version: "${cukesVersion}"
testImplementation group: 'io.cucumber', name: 'cucumber-core', version: "${cukesVersion}"
}

Add a junit-platform.properties file for cucumber junit properties

Springboot implementation

To support Junit5 and Cucumber as of the date of this walk-through we need to separate out the typical annotations into separate classes

Runner class

Configuration class

Feature files

In this example we want to ensure that any invalid values are caught before they are sent to the SendGrid API. We start off with one valid payload which will make it through our validation but will be 'caught' by our final mock before actually being sent. The rest of the cases have on missing or incorrect field per test and should be 'caught' before trying to call SendGrid and getting to our final mock.

Example - acceptance test

Last updated

Was this helpful?