ruby - 为什么我在 Cucumber 中得到 'Undefined dynamic step'?

标签 ruby cucumber automated-tests

我有以下步骤定义(只是为了说明我的问题):

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

在我的功能文件中,当我调用时:

When the calculator is run

我收到错误信息:

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'

根据文档,这应该有效。最初我有不同文件中的步骤,并认为也许我必须提供一些 include 指令,但现在即使步骤在同一个文件中也会发生。我错过了什么?

谢谢

最佳答案

在这一行中:

  step %{When xxx the calculator is run xxx}

删除“When”,它应该可以正常工作。

您可以在 cucumber docs 中查看.他们给出的 step 示例不包含单词“When”。

关于ruby - 为什么我在 Cucumber 中得到 'Undefined dynamic step'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37823874/

相关文章:

ruby - 续集迁移器未定义

java - 我可以在 cucumber 测试中使用 Spring 自动连接 Controller 吗?

javascript - 如何在 Testcafe 中打印页面对象的字符串值?

automated-tests - 自动化浏览器测试的简短通用术语是什么?

ruby - 如何将 JSON 转换为散列、搜索和更改值

ruby-on-rails - 为什么在引用对象属性时应该使用字符串而不是符号?

javascript - 在 Cucumber.js 中是否可以列出所有可用的步骤?

testing - 如何在Postman中检查json模式?

ruby - 使用索引无限次地做某事

CodeMirror 的 cucumber 测试