黄瓜找不到步骤定义 [英] Cucumber not finding step definitions

查看:29
本文介绍了黄瓜找不到步骤定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Cucumber 就是找不到步骤定义.文件结构(仅 Rails 根目录中的 specs 文件夹)如下所示:

My Cucumber just won't find the step definitions. The file structure (Only the specs folder inside the Rails root) looks like this:

-> specs
   -> features
      -> main_structure.feature
      -> step_definitions
         -> main_structure_steps.rb

这是 main_structure.feature:

This is the main_structure.feature:

Feature: Main structure
  Scenario: Viewing the Structure page
    When I am on the structure page

这是 main_structure_steps.rb:

And this the main_structure_steps.rb:

When(/^I am on the structure page$/) do
  visit '/'
end

现在我像这样运行黄瓜命令:

Now I run the cucumber command like this:

→ cucumber spec/features -r features 

我得到这个输出:

Using the default profile...
Feature: Main structure

  Scenario: Viewing the Structure page # spec/features/main_structure.feature:2
    When I am on the structure page    # spec/features/main_structure.feature:3
      Undefined step: "I am on the structure page" (Cucumber::Undefined)
      spec/features/main_structure.feature:3:in `When I am on the structure page'

1 scenario (1 undefined)
1 step (1 undefined)
0m0.229s

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

When(/^I am on the structure page$/) do
  pending # express the regexp above with the code you wish you had
end

/Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1037:in `block in process_args': invalid option: -r (OptionParser::InvalidOption)
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1016:in `new'
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1016:in `process_args'
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1066:in `_run'
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1059:in `run'
    from /Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:795:in `block in autorun'

底部还有一条错误消息,当我在 RubyMine 中运行测试时不会出现该消息.但在这两种情况下,都找不到步骤定义.这是 Rubymine 的输出:

There is also an error message at the bottom, that doesn't appear when I run the test in RubyMine. But in both cases, the step definitions are not found. This is the Rubymine output:

Testing started at 21:29 ...


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

When(/^I am on the structure page$/) do
  pending # express the regexp above with the code you wish you had
end
1 scenario (1 undefined)
1 step (1 undefined)
0m0.001s

Process finished with exit code 0

如果您需要任何其他信息,请告诉我.

Tell me if you need any additional infos.

推荐答案

尝试

cucumber spec/features/main_structure.feature -r spec/features

这篇关于黄瓜找不到步骤定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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