Cucumber has deprecated Given/Then/When in 4.7 - what should they be replaced by?

user304582 :

I recently upgraded my Cucumber/Java-based test tool by upgrading the Cucumber dependencies from 4.3.1 to 4.7.0. Now Eclipse reports that the Then tag is deprecated. For example, in my Step Definition class, Eclipse reports a warning that The type Then is deprecated next to this method:

@Then("Invoke the Functional API")
public void invoke_the_functional_api(DataTable dataTable) {
    /* Body of step definition */
}

The body of this step definition does not reference any other step definitions. Normally, when I see a deprecated warning, I would investigate how to replace the deprecated usage with more up-to-date code, but I can't work out what that would be in this case. Does anyone know?

Marit :

The tag itself is not deprecated. The import is. You'll need to update your import statements to the new import.

" Migration info for deprecated classes (as of cucumber-jvm v4.5.x):

import io.cucumber.junit.CucumberOptions

import io.cucumber.junit.Cucumber

You can replace java8 lambda imports with io.cucumber.java8.En

And java with io.cucumber.java.en.Given

If you run via IDEA change the main class in the run configuration: io.cucumber.core.cli.Main."

Link to issue in the Cucumber docs: https://github.com/cucumber/docs.cucumber.io/issues/142#issuecomment-508719509

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=125185&siteId=1