我正在尝试在自动化测试套件中设置Cucumber。我目前正在使用Ruby 2.0,但Ruby 2.2也存在同样的问题。
我尝试过Cucmber 2.0.0以及2.0.0.beta.3。无论是Ruby 2.0还是2.2,它们都没有任何兼容性。
每次我尝试运行我的.feature文件时,都会收到同样的错误。 Cucumber声称可与任何版本的Ruby> = 1.9.3(https://rubygems.org/gems/cucumber)兼容,但这似乎不是真的。
还有其他人看到此错误吗?有没有其他人成功使用Cucumber 2.0.0与Ruby 2.0或2.2?如果是这样,你运行ruby --version
时Gemfile中有哪些宝石以及ruby的具体更新/版本会出现什么?
**如果我恢复到旧版本的Cucumber(我尝试过1.3.3),我可以正确运行我的.feature文件。但我正在从头开始构建一个新的测试套件,并希望借此机会使用所有可能宝石的最新版本。我不想围绕已弃用的Cucumber版本构建我的Gemfile。
`Cucumber::Ast` no longer exists. These classes have moved into the `Cucumber::Core::Ast` namespace, but may not have the same API. (RuntimeError)
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/ast.rb:10:in `const_missing'
C:/Program Files (x86)/JetBrains/RubyMine 6.3/rb/testing/patch/bdd/teamcity/cucumber/common.rb:210:in `scenario_outline?'
C:/Program Files (x86)/JetBrains/RubyMine 6.3/rb/testing/patch/bdd/teamcity/cucumber/common.rb:218:in `tc_before_feature_element'
C:/Program Files (x86)/JetBrains/RubyMine 6.3/rb/testing/patch/bdd/teamcity/cucumber/formatter_03103.rb:98:in `before_feature_element'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/ignore_missing_messages.rb:10:in `method_missing'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/legacy_api/adapter.rb:521:in `before'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/legacy_api/adapter.rb:394:in `switch_to_child'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/legacy_api/adapter.rb:316:in `switch_step_container'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/legacy_api/adapter.rb:242:in `after_test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/legacy_api/adapter.rb:85:in `after_test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/legacy_api/adapter.rb:37:in `after_test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/fanout.rb:16:in `block in method_missing'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/fanout.rb:15:in `each'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/formatter/fanout.rb:15:in `method_missing'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/runner.rb:18:in `test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/case.rb:21:in `describe_to'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/filters/prepare_world.rb:11:in `test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/case.rb:21:in `describe_to'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/filters/apply_around_hooks.rb:8:in `test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/case.rb:21:in `describe_to'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/filters/apply_after_hooks.rb:5:in `test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/case.rb:21:in `describe_to'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/filters/apply_before_hooks.rb:5:in `test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/case.rb:21:in `describe_to'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/filters/apply_after_step_hooks.rb:8:in `test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/case.rb:21:in `describe_to'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/filters/activate_steps.rb:8:in `test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/case.rb:21:in `describe_to'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/filters/quit.rb:11:in `test_case'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/case.rb:21:in `describe_to'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/filters/locations_filter.rb:17:in `block in done'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/filters/locations_filter.rb:16:in `each'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/filters/locations_filter.rb:16:in `done'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/filter.rb:61:in `done'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/test/filters/tag_filter.rb:18:in `done'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/compiler.rb:23:in `done'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core/gherkin/parser.rb:31:in `done'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core.rb:29:in `parse'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-core-1.1.3/lib/cucumber/core.rb:18:in `compile'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/runtime.rb:70:in `run!'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/lib/cucumber/cli/main.rb:38:in `execute!'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-2.0.0/bin/cucumber:9:in `<top (required)>'
C:/Ruby200/bin/cucumber:23:in `load'
C:/Ruby200/bin/cucumber:23:in `<top (required)>'
-e:1:in `load'
**更新:当我通过Windows Shell
运行文件时,它成功运行且没有错误。
答案 0 :(得分:10)
症状: 您可以在cucumber命令行下运行测试,但无法在RubyMine下运行它,您收到错误:
错误的参数数量(1为3..4) 创建格式化程序时出错:Teamcity :: Cucumber :: Formatter(ArgumentError) C:/ Program Files(x86)/ JetBrains / RubyMine 7.0.4 / rb / testing / patch / bdd / teamcity / cucumber / formatter_03103.rb:22:在`initialize&#39;
我找到了一个更简单的解决方案: 只要去Rubymine - &gt;运行 - &gt;编辑配置,转到Runner选项,添加 &#34; - 格式漂亮&#34;这将覆盖不兼容的Teamcity问题并顺利运行。
HTH
答案 1 :(得分:0)
在@Johnson的帮助下,我确定了这个问题。它是由TeamCity formatter
引起的,它是每个(或至少版本6.x和7.x)Rubymine安装的一部分。
TeamCity格式化程序有一个名为cucumber
的目录,可在JetBrains\RubyMine 6.3\rb\testing\patch\bdd\teamcity\cucumber
找到。该目录包含名为common.rb
的文件。
我修改了名为scenario_outline?
的方法,该方法位于common.rb的208行,位于:
C:\Program Files (x86)\JetBrains\RubyMine 6.3\rb\testing\patch\bdd\teamcity\cucumber
我评论了这个方法的当前定义,并将其重写为:
def scenario_outline?(feature_element)
if defined? ::Cucumber::Core::Ast
feature_element.class == ::Cucumber::Core::Ast::ScenarioOutline
else
feature_element.class == ::Cucumber::Ast::ScenarioOutline
end
end
这解决了我的问题,我可以通过Rubymine成功运行Cucumber测试。
我认为这里的首要问题是TeamCity格式化程序似乎与Cucumber 2.0.0不兼容,因为Ast
上的::Cucumber::Ast::ScenarioOutline
模块已放在Core
内位于::Cucumber::Core::Ast::ScenarioOutline
答案 2 :(得分:0)
看起来@FluffyKittens solution有效。但是,对我来说问题是RubyMine 2016.安装RubyMine 2017解决了我的问题。我想RubyMine 2017和Cucumber 3.1之间存在关系。