Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting scenario and steps undefined in cucumber with java

I have been battling with this since 2 days. My test is shown passed but the test is not running in cucumber+java for Selenium webdriver test. In the console I am getting following message

1 Scenarios (1 undefined)
4 Steps (4 undefined)
0m0.000s


You can implement missing steps with the snippets below:

@Given("^User navigate to shopping page$")
public void user_navigate_to_shopping_page() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^user enters data$")
public void user_enters_data() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^clicks on search button$")
public void clicks_on_search_button() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Then("^product should be displayed$")
public void product_should_be_displayed() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

I have written following runner class

package stepDefinition;
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;


@RunWith(Cucumber.class)
@CucumberOptions(
        monochrome=true,
        features = "src/main/resources/feature",
    glue="src/test/java/stepDefinition",
    tags={"@tag2"},
    dryRun = false)
public class TestRunner {   
}

I will also attach the screenshot of directory structure of the project

and the feature file is

[![Feature: Checking Functionality
This is a demo test

@tag2
Scenario: Test Login
    Given User navigate to shopping page
    When user enters data
    And clicks on search button
    Then product should be displayed

enter image description here

like image 559
nikhil udgirkar Avatar asked Aug 31 '25 18:08

nikhil udgirkar


1 Answers

The way you have given the value of glue is incorrect. You have to give in java package format. Try glue = "stepDefinition" instead.

If you had a package inside your current stepDefinition package lets say steps which has the code. Then glue becomes "stepDefinition.steps"

You should move your features to the test\resources folder.

like image 79
Grasshopper Avatar answered Sep 02 '25 07:09

Grasshopper