Search code examples
cucumber-junit

Junit5 Cucumber "No definition found for..." in .feature file


I'm trying to create a simple Junit5-Cucumber project (in Eclipse) that would be used for UI testing.

I took reference from this repo:https://github.com/cucumber/cucumber-java-skeleton

Issue: No definition found for Open the Chrome and launch the application (error happens to the Given, When and Then statements) in the test_features.feature file.

# test_features.feature
Feature: Reset functionality on login page of Application

    Scenario: Verification of Reset button
    
       Given Open the Chrome and launch the application
        
       When Enter the username and password
        
       Then Reset the credentials
# RunCucumberTest.java
package lpms.cucumber;
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;

import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("lpms/cucumber")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "lpms.cucumber")
public class RunCucumberTest {
}
# StepDefinitions.java
package lpms.cucumber;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

public class StepDefinitions {
    @Given("^Open the Chrome and launch the application$")
    public void open_the_chrome_and_launch_the_application() throws Throwable
    {
        System.out.println("This step opens the chrome and launches the application");      
    }
    
    @When("^Enter the username and password$")
    public void enter_the_username_and_password() throws Throwable
    {
        System.out.println("This step enters the username and password on the login page");     
    }
     
    @Then("^Reset the credentials$")
    public void reset_the_credential() throws Throwable
    {
        System.out.println("This step clicks on the reset button.");
    }
}

Project Structure

IMAGE OF MY PROJECT STRUCTURE


Solution

  • Solved!

    It's a warning from Eclipse IDE, likely just a bug, because I can still get testing done.

    Sidenote: Extremely useful guide for learning the latest cucumber: https://cucumber.io/docs/guides/10-minute-tutorial/