Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 690
user304582 Avatar asked Jul 22 '19 23:07

user304582


2 Answers

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

like image 181
Marit Avatar answered Oct 02 '22 00:10

Marit


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?

In your IDE you can use ctrl + Click or fn + Click to step to the source code of an element. Your IDE will then usually also ask you if you want to download the sources. You should do this. The Javadoc in the source code will tell you what the recommended class to migrate to is.

like image 32
M.P. Korstanje Avatar answered Oct 02 '22 00:10

M.P. Korstanje