'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 1:[1]

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/

Solution 2:[2]

I had the same problem on my project and i'll post my solution here.

I've used Eclipse + Java 11 + SpringBoot 2.6.4

pom.xml dependencies

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <scope>test</scope>
        <version>7.3.0</version>
    </dependency>
    
   <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-suite</artifactId>
        <scope>test</scope>
    </dependency>
    
    <dependency>
       <groupId>io.cucumber</groupId>
       <artifactId>cucumber-junit-platform-engine</artifactId>
       <version>7.3.0</version>
       <scope>test</scope>
    </dependency>

pom.xml plugin in build section

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <properties>
                    <configurationParameters>
                        cucumber.junit-platform.naming-strategy=long
                    </configurationParameters>
                </properties>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
        </plugin>

After that, i've created a package in src/test/java called

filelife/skynet/cucumber

In this package i've created my steps class and my runner class; Steps class contains only some logging instrauctions, it doesn't verify nothing yet.

Steps class:

    @Slf4j
public class SendMessagesOnServiceLimitsSteps {
    
    @Given("A ServiceLimits Module with PosTXRate of {int} seconds")
    public void a_service_limits_module_with_pos_tx_rate_of_seconds(Integer posTxRate) {
        log.info("ServiceLimits PosTxRate {}", posTxRate);
        System.out.println("Given Step");
    }

    @When("I keyOn the device")
    public void i_key_on_the_device() {
        System.out.println("Given Step");
    }

    @When("i wait for {int} seconds")
    public void i_wait_for_seconds(Integer int1) {
        System.out.println("Given Step");
    }

    @When("i keyOff the device")
    public void i_key_off_the_device() {
        System.out.println("Given Step");
    }

    @Then("PositionData messages should be {int} or {int}")
    public void position_data_messages_should_be_or(Integer int1, Integer int2) {
        System.out.println("Given Step");
    }

    @Then("device log print {string}")
    public void device_log_print(String string) {
        System.out.println("Given Step");
    }

}

And my runner tests class:

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("filelife/skynet/cucumber")
@ConfigurationParameter(
   key = GLUE_PROPERTY_NAME,
   value = "filelife.skynet.cucumber"
)
public class SkynetTest{

}

I've also created the same folder path (filelife/skynet/cucumber) in src/test/resources source folder and i've pasted my .feature file.

In the end, i've created 2 files:

cucumber.properties

junit-platform.properties

in same source folder src/test/resources containg, both of them, string:

cucumber.publish.quiet=true

This configuration works with:

mvn tests

and

right click on SkynetTest -> RunAs -> Junit Test

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kj0902
Solution 2 File_life