gpt4 book ai didi

cucumber - Gherkin 语法中的数组占位符

转载 作者:行者123 更新时间:2023-12-02 22:14:34 29 4
gpt4 key购买 nike

嗨,我正在尝试用小 cucumber 语法编写表达一组要求,但它需要大量重复。我看到here我可以使用占位符,这对于我的任务来说是完美的,但是我的 Give 和 then 中的一些数据是集合。我将如何在示例中表示集合?

Given a collection of spaces <spaces>
And a <request> to allocate space
When I allocate the request
Then I should have <allocated_spaces>

Examples:
| spaces | request | allocated_spaces |
| ? | ? | ? |

最佳答案

有点 hacky,但你可以分隔字符串:

Given a collection of spaces <spaces>
And a <request> to allocate space
When I allocate the request
Then I should have <allocated_spaces>

Examples:
| spaces | request | allocated_spaces |
| a,b,c | ? | ? |

Given(/^a collection of spaces (.*?)$/) do |arg1|
collection = arg1.split(",") #=> ["a","b","c"]
end

关于cucumber - Gherkin 语法中的数组占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29014166/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com