黄瓜不会根据大纲场景找到我的步骤

问题描述 投票:0回答:1

我正在尝试做一个简单的测试女巫是水豚去页面,根据风景填写一个字段,并验证我是否在页面中有一些文本(我知道这是一个无用的测试,但只是一个POC),但黄瓜不会找到我获取示例数据的步骤并查找静态步骤。这是文件

。特征:

Given que eu estou na página
When eu escrever no campo o nome <name>
Then deve ver receber a mensagem "Back"
scenary:
| name |
| wolo |
| xala |

步骤:

When /^eu escrever no campo o nome "(.*?)"$/ do |name|
   fill_in "usuario_nome", :with=> name
end

这是我的日志:

You can implement step definitions for undefined steps with these snippets:

When("eu escrever no campo o nome wolo") do
  pending # Write code here that turns the phrase above into concrete actions
end

When("eu escrever no campo o nome xala") do
  pending # Write code here that turns the phrase above into concrete actions
end
ruby-on-rails regex cucumber capybara
1个回答
1
投票

它没有找到你的步骤,因为你的步骤指定“s是必需的但是当你在你的场景中调用它时没有引号。你需要改变你的测试才能拥有

When eu escrever no campo o nome "<name>"

或将您的步骤定义更改为

When /^eu escrever no campo o nome (.*?)$/ do |name|
  fill_in "usuario_nome", :with=> name
end

注意:如果使用最新版本的Cucumber,您还可以使用黄瓜表达式定义您的步骤

When "eu escrever no campo o nome {string}" do |name|
  fill_in "usuario_nome", :with=> name
end
© www.soinside.com 2019 - 2024. All rights reserved.