Is it possbile to have a null value on Example table on Cucumber Scenario Outline? [duplicate]

半世苍凉 提交于 2020-01-14 22:45:44

问题


Here is my example table on my scenario outline, some does not have value, is this possible?

Examples:

|ID   | UserName   | Password  | Contact1 | Number       |

|ID1  | username1  | password1 | Phone    | 111 222 4444 |

|ID2  | username2  | password2 |          |              |

|ID3  | username3  | password3 | Email    | a@a.com      |

|ID4  | username4  | password4 |          |              |

回答1:


The empty value will be considered a String if the feature step looks something like this:

Given ...
When I enter my "<Username>" and "<Password>"
And I enter my "<Contact>"
And I enter my "<Number>"
Then ...

You can manage the empty string inside the step definition:

@When("^I enter my \"([^\"]*)\"$")
public void I_enter_my(String contact) throws Throwable {
    // Handle empty string as null
    throw new PendingException();
}

Just an exmple, not sure if the code will work. Hope it helps.



来源:https://stackoverflow.com/questions/45081350/is-it-possbile-to-have-a-null-value-on-example-table-on-cucumber-scenario-outlin

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