gpt4 book ai didi

cucumber - cucumber 中的可选参数

转载 作者:行者123 更新时间:2023-12-02 13:18:58 32 4
gpt4 key购买 nike

我有一个步骤定义,我希望其中有一个可选参数。我相信两次调用此步骤的示例比其他任何内容都更好地解释了我所追求的内容。

I check the favorite color count
I check the favorite color count for email address 'john@anywhere.example'

首先,我想使用默认电子邮件地址。

定义此步骤的好方法是什么?我不是正则表达式专家。我尝试这样做,但 cucumber 给了我一个关于正则表达式参数不匹配的错误:

Then(/^I check the favorite color count (for email address "([^"]*))*"$/) do  |email = "default_email@somewhere.example"|

最佳答案

可选.功能:

Feature: Optional parameter

Scenario: Use optional parameter
When I check the favorite color count
When I check the favorite color count for email address 'john@anywhere.example'

可选_steps.rb

When /^I check the favorite color count(?: for email address (.*))?$/ do |email|
email ||= "default@domain.example"
puts 'using ' + email
end

输出

Feature: Optional parameter

Scenario: Use optional parameter
When I check the favorite color count
using default@domain.example
When I check the favorite color count for email address 'john@anywhere.example'
using 'john@anywhere.example'

1 scenario (1 passed)
2 steps (2 passed)
0m0.047s

关于cucumber - cucumber 中的可选参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18346348/

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