黄瓜没有找到步骤定义 [英] Cucumber not finding step definitions
问题描述
我的黄瓜只是不会找到步骤定义。文件结构(只有Rails根目录下的specs文件夹)如下所示:
- > specs
- >特征
- > main_structure.feature
- > step_definitions
- > main_structure_steps.rb
这是main_structure.feature:
特性:主要结构
场景:查看结构页面
当我在结构页面时
这是main_structure_steps.rb:
/ ^我在结构页$ /)do
访问'/'
结束
$ b b
现在我以这样的方式运行cucumber命令:
→cucumber spec / features -r features
我得到这个输出:
使用默认配置文件...
功能:主结构
方案:查看结构页#spec / features / main_structure.feature:2
结构页#spec / features / main_structure.feature:3
未定义的步骤:我在结构页(Cucumber :: Undefined)
spec / features / main_structure.feature:3:当我在结构页'
1情景(1未定义)
1步(1未定义)
0m0.229s
这些片段的未定义步骤的步骤定义:
当(/ ^我在结构页$ /)do
pending#使用您希望的代码表达regexp
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':无效选项:-r(OptionParser :: InvalidOption)
来自/Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/ lib / minitest / unit.rb:1016:in'new'
从/Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest /unit.rb:1016:in`process_args'
从/Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit。 rb:1066:在`_run'
从/Users/rudolf/.rvm/gems/ruby-2.0.0-p247@global/gems/minitest-4.7.5/lib/minitest/unit.rb:1059 :在`run'
从/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输出:
测试开始于21:29 ...
您可以使用以下代码片段来实现未定义步骤的步骤定义:
当(/ ^我在结构页面$ /)do
pending#使用您希望的代码表达上述regexp你有
end
1情景(1未定义)
1步(1未定义)
0m0.001s
进程已完成退出代码0
告诉我是否需要任何其他信息。
解决方案尝试
cucumber spec / features / main_structure.feature -r spec / features
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
This is the main_structure.feature:
Feature: Main structure Scenario: Viewing the Structure page When I am on the structure page
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
I get this output:
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'
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.
解决方案Try
cucumber spec/features/main_structure.feature -r spec/features
这篇关于黄瓜没有找到步骤定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!