title: cucumber.runtime.CucumberException: There are undefined steps
body: <p>Getting error as "There are undefined steps" while running the cucumber test with testNG in intelliJ editor, please guide with the steps that are missing </p>
  
  <p>the error output as </p>
  
  <pre><code> Feature: New Tour Login Testing
  
    Scenario: Valid data testing           # src/main/java/features/loginnewtour.feature:2
      Given user is already on Login Page
      When title of login page is new tour
      Then user enters "mercury"
  
  cucumber.runtime.CucumberException: cucumber.runtime.CucumberException: There are undefined steps
  
      at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:69)
      at cucumber.api.testng.AbstractTestNGCucumberTests.feature(AbstractTestNGCucumberTests.java:21)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
      at org.testng.TestRunner.privateRun(TestRunner.java:782)
      at org.testng.TestRunner.run(TestRunner.java:632)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
      at org.testng.SuiteRunner.run(SuiteRunner.java:268)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
      at org.testng.TestNG.run(TestNG.java:1064)
      at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
      at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
  Caused by: cucumber.runtime.CucumberException: There are undefined steps
      at cucumber.api.testng.FeatureResultListener.collectError(FeatureResultListener.java:60)
      at cucumber.api.testng.FeatureResultListener.result(FeatureResultListener.java:45)
      at cucumber.runtime.Runtime.runStep(Runtime.java:282)
      at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
      at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
      at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
      at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
      at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
      ... 24 more
  
  
  Undefined scenarios:
  src/main/java/features/loginnewtour.feature:2 # Scenario: Valid data testing
  
  1 Scenarios (1 undefined)
  3 Steps (3 undefined)
  0m0.000s
  </code></pre>
  
  <p>Below are the files that I am using under </p>
  
  <p>src/main/java/
    features
       loginnewtour.feature
    myRunner
       TestRunner.java
    stepDef
       loginstepdefnewtour.java</p>
  
  <p>I have a feature file  as "loginnewtour.feature"</p>
  
  <pre><code>Feature: New Tour Login Testing
    Scenario: Valid data testing
      Given user is already on Login Page
      When title of login page is new tour
      Then user enters "mercury"
  </code></pre>
  
  <p>implemented all steps mentioned in the feature file as "loginstepdefnewtour.java" </p>
  
  <pre><code>package stepDef;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import cucumber.api.java.en.Given;
  import cucumber.api.java.en.Then;
  import cucumber.api.java.en.When;
  import org.openqa.selenium.chrome.ChromeDriver;
  
  public class loginstepdefnewtour {
  
      WebDriver driver;
  
      @Given("^user is already on Login Page$")
      public void user_is_already_on_Login_Page() throws Throwable {
          System.setProperty("webdriver.chrome.driver","c:\\Grid\\chromedriver.exe");
          driver = new ChromeDriver();
          driver.get("http://newtours.demoaut.com/");
      }
  
      @When("^title of login page is new tour$")
      public void title_of_login_page_is_new_tour() throws Throwable {
          String title = driver.getTitle();
          System.out.println(title);
      }
  
      @Then("^user enters \"([^\"]*)\"$")
      public void user_enters_and(String arg1, String arg2) throws Throwable {
          driver.findElement(By.name("userName")).sendKeys("sunil");
      }
  }
  </code></pre>
  
  <p>and "testrunner.java" is as </p>
  
  <pre><code>package myRunner;
  
  import cucumber.api.CucumberOptions;
  import cucumber.api.testng.AbstractTestNGCucumberTests;
  
  //@RunWith(Cucumber.class)
  @CucumberOptions(
          features = "src/main/java/features/loginnewtour.feature",
          glue={"src/main/java/stepDef/loginstepdefnewtour.java"}, 
          plugin= {"pretty","html:test-outout", "json:json_output/cucumber.json", "junit:junit_xml/cucumber.xml"}, 
          monochrome = true,
          strict = true, 
          dryRun = false
  )
  
  public class TestRunner extends AbstractTestNGCucumberTests{
  
  }
  </code></pre>