Skip to content

Error when running springboot with Cucmber and Serenity

I am trying to test my spring boot application using serenity-cucumber.

To do this , I have my entry point:


import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;

@CucumberOptions(features = "src/test/resources")
public class CucumberIntegrationTest {

Then my Baseclass to be used by step defs,


import io.cucumber.spring.CucumberContextConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest(classes = Application.class)
public class SpringIntegrationTest {


And , one of my step defs is running some dummy tests at this point to work as glue.


import org.springframework.beans.factory.annotation.Value;

public class StepDefs extends SpringIntegrationTest {

  private String configValue;

  @When("^the client calls /version$")
  public void the_client_issues_GET_version() throws Throwable {
    String s = configValue;
  @Then("^the client receives status code of (\d+)$")
  public void the_client_receives_status_code_of(int statusCode) throws Throwable {
    String s = configValue;
  @And("^the client receives server version (.+)$")
  public void the_client_receives_server_version_body(String version) throws Throwable {
    String s = configValue;

My feature class:

Feature: the version can be retrieved
        Scenario: client makes call to GET /version
            When the client calls /version
            Then the client receives status code of 200
            And the client receives server version 1.0

I have imported the following dependencies, (have also tried with testCompile):

testImplementation 'io.cucumber:cucumber-java:6.10.4'
testImplementation 'io.cucumber:cucumber-junit:6.10.4'
testImplementation 'io.cucumber:cucumber-spring:6.10.4'

testImplementation 'net.serenity-bdd:serenity-core:2.4.49'
testImplementation 'net.serenity-bdd:serenity-spring:2.4.49'
testImplementation 'net.serenity-bdd:serenity-junit:2.4.49'
testImplementation 'net.serenity-bdd:serenity-cucumber5:2.2.6'

When I am running the test , getting following error.

Exception in thread "main" java.lang.NoSuchMethodError: io.cucumber.core.options.CommandlineOptionsParser: method <init>()V not found
    at net.serenitybdd.cucumber.cli.Main.main(

During initial search , came across this post whic mentioned to import cucumber-java and cucumber-junit in one of the answers , but does not work.

Is this due to the depency?

I also followed the post from serenity-bdd, but unable to get this working.
Getting started with Cucumber and Serenity
Integration testing Spring



I would normally not answer my own question , but I see few similar questions on SO.

For my case, removing fixed the issue.
testCompile (“io.cucumber:cucumber-spring:6.10.4”)

However, to get the correct version of dependencies, if you are stuck in such issue, is to refer there github and check release notes and dependency tee.

For my case, the issue was on Cucumber-Serenity5.

So getting the dependecncies from build.gradle, worked.

Please note, the actual versions are defined in, gradle.proporties.