cucumber contradictory error messages

有些话、适合烂在心里 提交于 2019-12-11 10:15:59

问题


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...


回答1:


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.



来源:https://stackoverflow.com/questions/13560114/cucumber-contradictory-error-messages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!