数据中的空格 table 在黄瓜中无法正常工作
White spaces in data table not working properly in cucumber
如果给定的输入字符串在黄瓜数据 table 中包含 space,则无法正确获取输入请求。此外,我确实删除了尾随和前导 space 以确保没有隐藏的非法字符,但仍然在 java 代码中错误地接收到输入。任何建议肯定会有所帮助。
特征:Foo
@foo
Scenario Outline: sample run
Then send request <aoo> <boo> <coo> <doo>
Examples:
| aoo | boo | coo | doo |
| 200 | xyx | Do not disturb | true |
@Then("^send request (.*) (.*) (.*) (.*)$")
public void send_request(String aoo, String boo, String coo, String doo) throws Throwable {
System.out.println("aoo " + aoo);
System.out.println("boo " + boo);
System.out.println("coo " + coo);
System.out.println("doo " + doo);
}
预期输出:-
aoo 200
boo xyx
coo Do not disturb
doo true
实际输出:-
aoo 200 xyz Do
boo not
coo disturb
doo true
(.*) 是贪心的,匹配任意字符。你必须限制他们。如果可能,请尝试使用其他数据类型。 aoo
-> int
, doo
-> boolean
@foo
Scenario Outline: sample run
Then send request "<aoo>" "<boo>" "<coo>" "<doo>"
Examples:
| aoo | boo | coo | doo |
| 200 | xyx | Do not disturb | true |
@Then("^send request \"(.*)\" \"(.*)\" \"(.*)\" \"(.*)\"$")
public void send_request(String aoo, String boo, String coo, String doo) throws Throwable {
// omitted code
}
如果给定的输入字符串在黄瓜数据 table 中包含 space,则无法正确获取输入请求。此外,我确实删除了尾随和前导 space 以确保没有隐藏的非法字符,但仍然在 java 代码中错误地接收到输入。任何建议肯定会有所帮助。
特征:Foo
@foo
Scenario Outline: sample run
Then send request <aoo> <boo> <coo> <doo>
Examples:
| aoo | boo | coo | doo |
| 200 | xyx | Do not disturb | true |
@Then("^send request (.*) (.*) (.*) (.*)$")
public void send_request(String aoo, String boo, String coo, String doo) throws Throwable {
System.out.println("aoo " + aoo);
System.out.println("boo " + boo);
System.out.println("coo " + coo);
System.out.println("doo " + doo);
}
预期输出:-
aoo 200
boo xyx
coo Do not disturb
doo true
实际输出:-
aoo 200 xyz Do
boo not
coo disturb
doo true
(.*) 是贪心的,匹配任意字符。你必须限制他们。如果可能,请尝试使用其他数据类型。 aoo
-> int
, doo
-> boolean
@foo
Scenario Outline: sample run
Then send request "<aoo>" "<boo>" "<coo>" "<doo>"
Examples:
| aoo | boo | coo | doo |
| 200 | xyx | Do not disturb | true |
@Then("^send request \"(.*)\" \"(.*)\" \"(.*)\" \"(.*)\"$")
public void send_request(String aoo, String boo, String coo, String doo) throws Throwable {
// omitted code
}