I'm following this tutorial to set up BDD using Cucumber-JVM in a Java project. I've set up the following test file under my src/test/java
folder for a Java project that I'm working on in Eclipse:
CucumberTest.java
package myPackage;
import static org.junit.Assert.fail;
import java.io.IOException;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:Feature")
public class CucumberTest {
// error on line below 'When cannot be resolved to a type'
@When("^the step is invoked$")
public void myTestMethod() throws IOException {
}
}
I'm sure this is something simple (I'm relatively new to Cucumber for Java apps), and I believe I'm doing all of this in the correct place. How do I resolve the error? Using CTRL+SHIFT+O
(organise imports) doesn't automatically import whatever it is I need, and I've looked for a relevant package I may need to import, under the cucumber.api
, cucumber.api.junit
and cucumber.api.junit.Cucumber
namespaces, and there doesn't seem to be anything there that I should import. I've reviewed similar SO questions and haven't found any clues, as my issue is more specific.