tri*_*999 14 cucumber cucumber-jvm
我有一个Feature文件,如下所示:
Scenario Outline: Create ABC
Given I open the application
When I enter username as <username>
And I enter password as <password>
Then I enter title as <title>
And press submit
Examples:
| username | password | title |
| Rob | xyz1 | title1 |
| Bob | xyz1 | title2 |
Run Code Online (Sandbox Code Playgroud)
这要求我为每个值都有步骤定义.我可以改为
通用步骤定义,可以为每个用户名或密码或标题值映射
示例部分.
即而不是说
@When("^I enter username as Rob$")
public void I_enter_username_as_Rob() throws Throwable {
// Express the Regexp above with the code you wish you had
throw new PendingException();
}
Run Code Online (Sandbox Code Playgroud)
我可以进入
@When("^I enter username as <username>$")
public void I_enter_username_as_username(<something to use the value passed>) throws Throwable {
// Express the Regexp above with the code you wish you had
throw new PendingException();
}
Run Code Online (Sandbox Code Playgroud)
Bal*_*ala 32
你应该使用这种格式
Scenario Outline: Create ABC
Given I open the application
When I enter username as "<username>"
And I enter password as "<password>"
Then I enter title as "<title>"
And press submit
Run Code Online (Sandbox Code Playgroud)
哪个会产生
@When("^I enter username as \"([^\"]*)\"$")
public void I_enter_username_as(String arg1) throws Throwable {
// Express the Regexp above with the code you wish you had
throw new PendingException();
}
Run Code Online (Sandbox Code Playgroud)
arg1 现在将传递您的用户名/值.
| 归档时间: |
|
| 查看次数: |
46128 次 |
| 最近记录: |