我想在黄瓜功能文件的后台步骤中添加一个示例表。我该怎么做呢?
我想做这样的事情:
Background:
Given <username> has logged in
Examples:
|username|
|User 1 |
|User 2 |
Scenario: .....
答案 0 :(得分:3)
这对你有帮助..
Feature: Passing background with multiline args
Background:
Given table |a|b|
|c|d|
And multiline string """ I'm a cucumber
and I'm okay. I sleep all night and I test all day """
Scenario: passing background
Then the table should be
|a|b|
|c|d|
Then the multiline string should be """ I'm a cucumber and I'm okay. I sleep all night and I test all day
""" Scenario: another passing background
Then the table should be |a|b| |c|d|
Then the multiline string should be """ I'm a cucumber and I'm okay. I sleep all night and I test all day
有关更多方案,请参阅此链接..
https://www.relishapp.com/cucumber/cucumber/docs/gherkin/background
答案 1 :(得分:2)
不幸的是,这是不可能的。
黄瓜docs
答案 2 :(得分:0)
也许这可以帮助您:
Background:
Given Login with email myemail@mail.com and pass myPass
Scenario Outline:Scenario 1
Examples:
| thing1| thing2 | thing3 |
| fdlsk | fadsff | faskld |
在您的stepdef中使用它:
@Then("^Login Login with email ([^\"]*) and pass ([^\"]*)$")
public void login_general(String email, String pass) {
login.fillEmail(email);
login.fillPass(pass);
login.clickLogin();
}