黄瓜不读场景轮廓数据(Cucumber does not read data from scenar

2019-10-19 13:48发布

我有以下情形大纲

 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("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);
}

但是,当我执行测试,然后我得到下面的错误 -

您可以实现失踪与下面的代码片段步骤:

@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();
}

难道我执行的测试步骤错了吗?

Answer 1:

代替

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

做到这一点(注意双引号)

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


Answer 2:

我想补充,当亚军类,我们把错误的包步骤类的出现同样的错误

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

}

步骤类应该是存在并且包应该是正确的。



文章来源: Cucumber does not read data from scenario outline