3

I'm trying to create BDD tests for a spring boot application that is written in java11, and using junit5 for tests.

I'm trying version 6.9.1 of cucumber and my dependencies for this part are:

<dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-java8</artifactId>
      <version>${cucumber.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-junit-platform-engine</artifactId>
      <version>${cucumber.version}</version>
      <scope>test</scope>
    </dependency>

Without a single example I could find in the cucumber documentation I tried fuse some snippets I found online that show this dependency list to be sufficient however, when I try their samples, there I can't find any of the following:

  1. CucumberExtension - instead there is an annotation @Cucumber which seems to be doing that.
  2. @CucumberOptions - there is an interface CucmberOptions which I can implement and return all required properties, but this feels like a step back from the parameterized annotation.

Can anyone provide a guide, documentation, or any other way to achieve my goal?

Thanks

2
  • You might want to start with the following example: github.com/cronn/cucumber-junit5-example Commented Jan 9, 2021 at 7:19
  • This example is making the same mistake as the OP in thinking that Jupiter is required rather then the platform. Commented Jan 9, 2021 at 8:58

1 Answer 1

2

It's worth reading the introduction to JUnit 5. You are making a common mistake in thinking that JUnit 5 is a monolith. Rather:

https://junit.org/junit5/docs/current/user-guide/#overview-what-is-junit-5

Unlike previous versions of JUnit, JUnit 5 is composed of several different modules from three different sub-projects.

JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage

Like JUnit Jupiter, Cucumber is a test engine using the JUnit Platform. Extensions are a concept from JUnit Jupiter and don't carry over to Cucumber.

Without a single example I could find in the cucumber documentation.

You'll not find anything in the main documentation until the JUnit 5 integration is feature complete. Until that time it is perfectly possible to use Cucumbers JUnit 4 integration with JUnit Vintage.

However if you're more experimentally minded you can use the documentation with the source code:

https://github.com/cucumber/cucumber-jvm/tree/main/junit-platform-engine

@CucumberOptions - there is an interface CucmberOptions which I can implement and return all required properties, but this feels like a step back from the parameterized annotation.

The Cucumber JUnit Platform integration defaults to scanning for glue and features on the class path root. If you follow the conventional maven/gradle/java project layout no additional configuration is needed.

So step definitions go in src/test/java/com/example and features in src/test/resources/com/example.

If you have a more complicated setup you should either wait and use JUnit4/Junit Vintage or simplify your setup.

Sign up to request clarification or add additional context in comments.

1 Comment

While this wasn't the direct solution, it led me in the right direction. My application also has spring-boot in the mix, but I wanted to start slow and steady.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.