作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个步骤定义,我希望其中有一个可选参数。我相信两次调用此步骤的示例比其他任何内容都更好地解释了我所追求的内容。
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/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!