2011-10-03 76 views
2

在我cucumber.yml我試圖增加該選項(default: --drb --format progress),但它返回一個錯誤:當我把它在括號黃瓜「--format進步」不工作

Exception encountered: #<ArgumentError: wrong number of arguments (3 for 2) 
Error creating formatter: progress> 

default: --drb --"format progress"它不會幫助:

invalid option: --format progress (OptionParser::InvalidOption) 

所以也許沒有選擇,但it should be

和「格式相當」正常工作,沒有任何支架。 我不想看到控制檯中的所有場景,但只是哪個有錯誤,也許還有另一種方法可以做到這一點。

完全跟蹤:

wrong number of arguments (3 for 2) 
Error creating formatter: progress (ArgumentError) 
/home/alder/.rvm/gems/[email protected]/gems/activerecord-3.1.0/lib/active_record/base.rb:1543:in `initialize' 

/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:168:in `new' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:168:in `block in formatters' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:163:in `map' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:163:in `formatters' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:68:in `build_tree_walker' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/runtime.rb:42:in `run!' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/main.rb:43:in `execute!' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/main.rb:20:in `execute' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/bin/cucumber:14:in `<top (required)>' 
/home/alder/.rvm/gems/[email protected]/bin/cucumber:19:in `load' 
/home/alder/.rvm/gems/[email protected]/bin/cucumber:19:in `<main>' 

,如果我寫cucumer.yml錯誤略有不同的選項:

Exception encountered: #<ArgumentError: wrong number of arguments (3 for 2) 
Error creating formatter: progress> 
backtrace: 
/home/alder/.rvm/gems/[email protected]/gems/activerecord-3.1.0/lib/active_record/base.rb:1543:in `initialize' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:168:in `new' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:168:in `block in formatters' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:163:in `map' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:163:in `formatters' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/configuration.rb:68:in `build_tree_walker' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/runtime.rb:42:in `run!' 
/home/alder/.rvm/gems/[email protected]/gems/cucumber-1.1.0/lib/cucumber/cli/main.rb:43:in `execute!' 
/home/alder/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/test_framework/cucumber.rb:24:in `run_tests' 
/home/alder/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/run_strategy/forking.rb:13:in `block in run' 
/home/alder/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/forker.rb:21:in `block in initialize' 
/home/alder/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/forker.rb:18:in `fork' 
/home/alder/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/forker.rb:18:in `initialize' 
/home/alder/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/run_strategy/forking.rb:9:in `new' 
/home/alder/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/run_strategy/forking.rb:9:in `run' 
/home/alder/.rvm/gems/[email protected]/gems/spork-0.9.0.rc9/lib/spork/server.rb:48:in `run' 
/home/alder/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1558:in `perform_without_block' 
/home/alder/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1518:in `perform' 
/home/alder/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1592:in `block (2 levels) in main_loop' 
/home/alder/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1588:in `loop' 
/home/alder/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/drb/drb.rb:1588:in `block in main_loop' 

我的方式有叉勺也許這是一個問題。

回答

4

基於對你的問題的最新信息,我覺得我看到的問題(因此我張貼另一個答案,因爲它是完全不同於我的另一個)。它看起來像Cucumber試圖實例化一個ActiveRecord類,所以我懷疑你的項目中有一個名爲'Progress'的模型,而這個模型是Cucumber試圖創建的,而不是實際的格式化器。

我能夠重現您的問題(足夠接近,反正)通過在「支持」文件夾中添加此類:

class Progress 
    def initialize 
     raise "I don't exist!" 
    end 
end 

根據該文檔,你應該能夠指定一個完全合格的類這裏命名爲--format Cucumber::Formatter::Progress,強制Cucumber使用它自己的格式化程序。但是,我嘗試了這一點,但它仍然不起作用,似乎Cucumber解析完全限定名稱的方式存在一個錯誤。

我能夠加入這一行我env.rb文件來解決這個問題:

require 'cucumber/formatter/progress' 

,然後讓我成功運行cucumber --format progress

我認爲,由於env.rb在任何其他代碼之前被執行,所以Cucumber的Progress類將是第一個在創建格式化程序時找到的類。

+0

太棒了!非常感謝這樣的詳細回覆,我只是在'env'中添加'require'並且它可以工作! – zishe

0

看起來從你貼在輸出中,你有一個額外的角度(「>」)支架漂浮在你的cucumber.yml文件:

錯誤創建格式化:進展>

除非您的問題中存在拼寫錯誤,否則由於某些原因,Cucumber正在嘗試創建名爲「progress>」的格式器,因此您可能只需要查找並刪除多餘的角度支架。


編輯:這不是問題都沒有,看到my other answer

+0

沒有''',我試着在控制檯「黃瓜 - 格式化進度」,它也不起作用。 – zishe

+0

可以添加'--backtrace'參數,併發布輸出嗎? –

+0

也可以發佈您正在運行的完整命令行嗎? –