Cucumber does not read data from scenario outline

心已入冬 提交于 2019-12-11 12:34:29

问题


I have following scenario outline

 Background:
   Given customer is in hot or not page

 Scenario Outline: Hot article
  And customer enters <name>
  And submits
  And customer clicks thumbs up
  Then ensure the TBD

 Examples:
  | name |
  |  Elliot |
  |  Florian |

and following step implementation -

@And("customer enters <name>")
public void customer_enters_name(String name) throws Throwable {
    // Express the Regexp above with the code you wish you had
    Thread.sleep(10000);
}

But when I execute test then I get following error -

You can implement missing steps with the snippets below:

@Given("^customer enters Elliot$")
public void customer_enters_Elliot() throws Throwable {
  // Express the Regexp above with the code you wish you had
  throw new PendingException();
}

@Given("^customer enters Florian$")
 public void customer_enters_Florian() throws Throwable {
  // Express the Regexp above with the code you wish you had
  throw new PendingException();
}

Did I implement test steps wrong?


回答1:


Instead of

 Scenario Outline: ...
  And customer enters <name>
  ...

Do this (Note the double quotes)

 Scenario Outline: ...
  And customer enters "<name>"
  ...



回答2:


Just to add, The same error arise when in the runner class ,we put the wrong package of the step class

@CucumberOptions(glue = {"com.wrongpackage.step"})
public class TestRunner{

}

Step class should be present and the package should be correct.



来源:https://stackoverflow.com/questions/22358745/cucumber-does-not-read-data-from-scenario-outline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!