【问题标题】:Cucumber is not providing the method signatures for steps in the feature fileCucumber 没有为功能文件中的步骤提供方法签名
【发布时间】:2020-05-22 20:23:37
【问题描述】:

我正在尝试填写此演示网站上的字段:http://newtours.demoaut.com/mercuryregister.php

这是我的功能文件:

Feature: Testing Mercury Tours' register page

Background: 
    Given the user has launched their browser
    And the browser is on Mercury Tour's register page

Scenario Outline: Testing Mercury Tours' registration page via positive testing
    When the user enters the "<First Name>"
    And enters the "<Last Name>"
    And enters the "<Phone>"
    And enters the "<Email>"
    And enters the "<Address>"
    And enters the "<City>"
    And enters the "<State>"
    And enters the "<Postal Code>"
    And selects the "<Country>"
    And enters the "<User Name>"
    And enters the "<Password>"
    And enters the "<Confirm Password>"

Examples: 
  | First Name | Last Name | Phone          | Email            | Address          | City          | State | Postal Code | Country       | User Name | Password    | Confirm Password |
  | Bob        | Mayer     | 1-877-393-4448 | BobM@example.com | 123 Victory Lane | Beverly Hills | CA    |       90210 | United States | BobM      | 123password | 123password      |

当我运行这个特性文件时,Cucumber 给了我前两个步骤(名字和姓氏)和选择下拉菜单(fpr 国家)的方法签名,而不是其余的:

@When("^the user enters the \"([^\"]*)\"$")
public void the_user_enters_the(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^enters the \"([^\"]*)\"$")
public void enters_the(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@When("^selects the \"([^\"]*)\"$")
public void selects_the(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

如何实现填充其他文本字段(如电话号码、电子邮件和地址)的方法?

【问题讨论】:

  • 能否请您也向我们展示您的项目结构。我相信您在运行器文件中进行了错误的配置:)
  • 我没有使用跑步者课程;我正在运行功能文件

标签: cucumber cucumber-java


【解决方案1】:

其他“缺失”的步骤匹配相同的模式 - ^enters the \"([^\"]*)\"$ 是第二个。如果您希望 cucumber 为每个步骤发出步骤定义方法签名,请考虑使它们独一无二。将And enters the "&lt;Phone&gt;" 更改为And enters phone details - "&lt;Phone&gt;"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-27
    相关资源
    最近更新 更多