[英]Why do I get 'Undefined dynamic step' in Cucumber?
I have following step definitions (just to illustrate my problem): 我有以下步骤定义(只是为了说明我的问题):
When(/^the calculator is run$/) do
step %{When xxx the calculator is run xxx}
end
When(/^xxx the calculator is run xxx$/) do
@output = `ruby calc.rb #{@input}`
raise('Command failed!') unless $?.success?
end
In my feature file, when I call: 在我的功能文件中,当我打电话时:
When the calculator is run
I got the error message: 我收到了错误消息:
Undefined dynamic step: "When xxx the calculator is run xxx" (Cucumber::UndefinedDynamicStep)
./features/step_definitions/calculator_steps_when.rb:2:in `/^the calculator is run$/'
features/adding.feature:11:in `When the calculator is run'
features/adding.feature:6:in `When the calculator is run'
According to the documentation this should work. 根据文档,这应该工作。 Initially I had the steps in different files, and thought maybe I had to provide some include directive, but now it happens even when steps are in the same file.
最初我有不同文件中的步骤,并认为我可能必须提供一些include指令,但现在即使步骤在同一个文件中也会发生。 What am I missing?
我错过了什么?
Thanks 谢谢
In this line: 在这一行:
step %{When xxx the calculator is run xxx}
Remove the "When" and it should work correctly. 删除“何时”,它应该正常工作。
You can check this in the cucumber docs . 您可以在黄瓜文档中查看此内容。 The
step
example they give doesn't include the word "When". 他们给出的
step
示例不包括“何时”一词。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.