黄瓜矛盾的错误信息 [英] cucumber contradictory error messages

查看:328
本文介绍了黄瓜矛盾的错误信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题背景:使用web_steps.rb的黄瓜声明步骤定义堆栈溢出问题



在解决问题时出现两个矛盾的错误信息:

 当/ ^(?: | I)取消选中([^] *)$ / do | field | 
检查(字段)
end

'bundle exec cucumber features / filter_movie_list.feature'的执行结果为:

 取消选中ratings_G:

features / step_definitions / movie_steps.rb:65:in'/ ^(?: | I)取消选中([^] *)$ /
feature / step_definitions / web_steps.rb:65:in'/ ^(?: | I)取消选中([^] *)$ /

但是,删除步骤不会导致使用web_steps.rb的步骤定义;而是显示不同的错误消息:


当我取消选中以下评级时:G,PG-13#features / step_definitions / movie_steps.rb:44
未定义的步骤:当我取消选中 ratings>(Cucumber :: Undefined)
./features/step_definitions/movie_steps.rb:52:in`block(2 levels)in< top(required)>'
./features/在每个
./features/step_definitions/movie_steps.rb:49:in`/ I(un)?检查以下评级:(。*)/'
features / filter_movie_list.feature:30:in`当我取消选中以下评分:G,PG-13'

如果两个位置有两个定义,但后来抱怨当它的副本被删除时,没有定义同一个步骤,那么Cucumber可能会抱怨一个步骤是多余的?是否可能第二个错误消息真的意味着除了所陈述的之外的东西?



PS:配置是通过一个黄瓜安装与训练轮为CS169达到。 x1 @ edX ...

解决方案

看来你有一个定义 与调用有些匹配当我取消选中错误消息中出现的以下评级:G,P-13 。黄瓜抱怨没有什么匹配后者。

匹配可能会解释你最初得到的歧义警告。该定义匹配,但不是在字符串内部找到。


Problem Background: "cucumber declarative step definitions using web_steps.rb" Stack Overflow Question

In troubleshooting the problem in question two contradictory error messages are arrived at; with the statement:

When /^(?:|I )uncheck "([^"]*)"$/ do |field|
  check(field)
end

added to 'features/step_definitions/movie_steps.rb' execution of 'bundle exec cucumber features/filter_movie_list.feature' results in:

Ambiguous match of "I uncheck "ratings_G"":

features/step_definitions/movie_steps.rb:65:in '/^(?:|I )uncheck "([^"]*)"$/
features/step_definitions/web_steps.rb:65:in '/^(?:|I )uncheck "([^"]*)"$/

However, removal of the step does not result in the step definition from 'web_steps.rb' being utilized; rather, a different error message is displayed:

When I uncheck the following ratings: G, PG-13                 # features/step_definitions/movie_steps.rb:44
  Undefined step: "When I uncheck "ratings_G"" (Cucumber::Undefined)
  ./features/step_definitions/movie_steps.rb:52:in `block (2 levels) in <top (required)>'
  ./features/step_definitions/movie_steps.rb:49:in `each'
  ./features/step_definitions/movie_steps.rb:49:in `/I (un)?check the following ratings: (.*)/'
  features/filter_movie_list.feature:30:in `When I uncheck the following ratings: G, PG-13'

How is it possible for Cucumber to complain that a step is redundant when there are two definitions in two places but then later complain that the very same step is not defined when its duplicate is removed? Is it possible the second error message really means something other than what is stated?

PS: The configuration was arrived at by way of a Cucumber installation with training wheels for CS169.x1 @ edX...

解决方案

It seems that you have one definition called When I uncheck "ratings_G" that is somewhat matched with the call When I uncheck the following ratings: G, P-13 that occurs in the error message. Cucumber is complaining that nothing matches the latter one. Does it exist in your code?

The somewhat matching would possibly explain the ambiguity warning you got initially. The definition matches but not what is found inside the string.

这篇关于黄瓜矛盾的错误信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆