Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Cucumber Java 8 Lambda Definitions #84

Open
Hydragyrum opened this issue Nov 17, 2022 · 1 comment
Open

Support for Cucumber Java 8 Lambda Definitions #84

Hydragyrum opened this issue Nov 17, 2022 · 1 comment

Comments

@Hydragyrum
Copy link

Are the Java 8 style bindings supported with Quarkus-Cucumber?

When I try to define my StepDefs as such:

class ApiStepDefs : En {
  init {
    Given("A GET request to the API") {
     // code goes here
    }

    When("We execute the request to the {string} endpoint") { endpoint:String ->
      // code goes here
    }

    Then("We get a blank list as a response") {
      // more code here
    }
  }
}

The test errors out as if the stepdefs were undefined

Undefined scenarios:
classpath:com/example/features/integration/Api.feature:5 # Calling the GET the api without prior initialization returns a blank list

1 Scenarios (1 undefined)
3 Steps (2 skipped, 1 undefined)
0m0.091s

For completeness, the feature file is:

# Created by Dev at 2022-11-15
Feature: An API
  Details the API behaviour

  Scenario: Calling the GET the api without prior initialization returns a blank list
    Given A GET request to the API
    When We execute the request to the "/endpoint" endpoint
    Then We get a blank list as a response

and the Runner stub

package com.michelin.pmu.dojo.features.integration

import io.quarkiverse.cucumber.CucumberOptions
import io.quarkiverse.cucumber.CucumberQuarkusTest

@CucumberOptions(
  plugin = ["pretty", "summary", "me.jvt.cucumber.report.PrettyReports:build/reports/cucumber/integration"]
)
class RunCucumberApiTests : CucumberQuarkusTest()

The features, stepdefs and runner are all in the same package.

@Hydragyrum
Copy link
Author

Hydragyrum commented Nov 17, 2022

Addendum:

Converting to the old Cucumber StepDefs format works

class ApiStepDefs {

  @Given("A GET request to the API")
  fun a_GET_request_to_the_API() {
    // code
  }

  @When("We execute the request to the {string} endpoint")
  fun we_execute_the_request_to_the_endpoint(endpoint: String) {
    // code
  }

  @Then("We get a blank list as a response")
  fun we_get_a_blank_list_as_a_response() {
     // code
  }
}

I would like to be able to use the lambda style though, as it does slightly reduce some boilerplate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant