Cucumber won't run with Spork
I can run my cucumber tests without a Drb, but Cucumber raises an exception when I try to run using Spork. The stack crawl is below. I am running RM 2.0.2 RC (RM-93.130). BTW the problem also occurs running without the debugger.
2 Questions:
- how do I fix/work-around the problem
- can you recommend directions for how to debug the tests running under Drb? I tried setting a breakpoint in the code based on the stack crawl, and it when I ran it again, the breakpoint was hit once, and as far as I could tell the exception wasn't raised, but continuing from that point ended up with the stack crawl below.
/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) /home/jeff/.gem/ruby/1.8/bin/rdebug-ide --port 44024 -- /home/jeff/projects/foo/script/cucumber /home/jeff/projects/foo/features/manage_gtds.feature --format Teamcity::Cucumber::Formatter --expand --color
Testing started at 12:07 AM ...
Fast Debugger (ruby-debug-ide 0.4.9) listens on :44024
Using the default profile...
Disabling profiles...
Exception encountered: #<RuntimeError: All but one formatter must use --out, only one can print to each stream (or STDOUT)>
backtrace:
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/lib/cucumber/cli/configuration.rb:173:in `arrange_formats'
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/lib/cucumber/cli/configuration.rb:26:in `parse!'
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/lib/cucumber/cli/main.rb:91:in `configuration'
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/lib/cucumber/cli/main.rb:38:in `execute!'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/test_framework/cucumber.rb:22:in `run_tests'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/forking.rb:13:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/magazine/../../../spork/forker.rb:21:in `initialize'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/magazine/../../../spork/forker.rb:18:in `fork'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/magazine/../../../spork/forker.rb:18:in `initialize'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/forking.rb:9:in `new'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/run_strategy/forking.rb:9:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/server.rb:47:in `run'
/usr/lib/ruby/1.8/drb/drb.rb:1563:in `__send__'
/usr/lib/ruby/1.8/drb/drb.rb:1563:in `perform_without_block'
/usr/lib/ruby/1.8/drb/drb.rb:1523:in `perform'
/usr/lib/ruby/1.8/drb/drb.rb:1597:in `main_loop'
/usr/lib/ruby/1.8/drb/drb.rb:1593:in `loop'
/usr/lib/ruby/1.8/drb/drb.rb:1593:in `main_loop'
/usr/lib/ruby/1.8/drb/drb.rb:1589:in `start'
/usr/lib/ruby/1.8/drb/drb.rb:1589:in `main_loop'
/usr/lib/ruby/1.8/drb/drb.rb:1438:in `run'
/usr/lib/ruby/1.8/drb/drb.rb:1435:in `start'
/usr/lib/ruby/1.8/drb/drb.rb:1435:in `run'
/usr/lib/ruby/1.8/drb/drb.rb:1355:in `initialize'
/usr/lib/ruby/1.8/drb/drb.rb:1635:in `new'
/usr/lib/ruby/1.8/drb/drb.rb:1635:in `start_service'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/server.rb:29:in `listen'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/lib/spork/server.rb:20:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/bin/../lib/spork/runner.rb:75:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/bin/../lib/spork/runner.rb:9:in `run'
/home/jeff/.gem/ruby/1.8/gems/spork-0.8.2/bin/spork:10
/home/jeff/.gem/ruby/1.8/bin/spork:19:in `load'
/home/jeff/.gem/ruby/1.8/bin/spork:19
-e:1:in `load'
-e:1
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/bin/cucumber:11:in `exit'
/home/jeff/.gem/ruby/1.8/gems/cucumber-0.6.4/bin/cucumber:11
/home/jeff/projects/foo/script/cucumber:9:in `load'
/home/jeff/projects/foo/script/cucumber:9
/home/jeff/.gem/ruby/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in `debug_load'
/home/jeff/.gem/ruby/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in `debug_program'
/home/jeff/.gem/ruby/1.8/gems/ruby-debug-ide-0.4.9/bin/rdebug-ide:87
/home/jeff/.gem/ruby/1.8/bin/rdebug-ide:19:in `load'
/home/jeff/.gem/ruby/1.8/bin/rdebug-ide:19
-e:1:in `load'
-e:1
Uncaught exception: exit
Empty test suite.
Process finished with exit code 0
Please sign in to leave a comment.
I have the same problem.
Hi guys,
It's a Cucumber bug. See details and workaround in http://youtrack.jetbrains.net/issue/RUBY-5920 issue
Hi Roman,
", AFAIK.Thanks for being so responsive (as usual =). I'm enough of a cucumber/rails newbie that I'm going to need you to indicate the specific changes to the cucumber.yml file. I took a look at my rerun.txt file, and it existed but was empty. So, the rerun_opts local variable would resolve to just, "
I was able to get the cucumber tests to run by making the following changes:
- std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
+ std_opts = "--format rerun --out rerun.txt --strict --tags ~@wip"
but I don't understand enough about the formatters and purpose of rerun to understand the impact of this change.
Cucumber allows to subscribe listeners on it's internal events (feature started, step passed/failed/ignored, etc.). Such listeners represent tests results for user. RubyMine also provides a listener which is responsible to interaction with RubyMine test runner UI.
Rerun - is new feature of cucumber. At first tests launch cucumber will run all features in "features" folder. Then "rerun" formatter will save failed features names in rerun.txt file. At second launch cucumber will run only failed features mentioned in rerun.txt. If rerun.txt is empty cucumber will run all features in project again. RubyMine doesn't know about this new cucumber feature and doesn't support it (see http://youtrack.jetbrains.net/issue/RUBY-5922, http://youtrack.jetbrains.net/issue/RUBY-5923). RubyMine always passes name of feature file/folder which you want to test and overrides "rerun" behaviour.
Cucumber doesn't allow to use more than 1 formatter which outputs data to stdout stream, all other formatters must redirect their output to some file
Firstly RubyMine attaches our custom tests results formatter (just to show results in nice GUI) to $stdout and then cucumber.yml also attaches "progress" formatter. So you will get "Exception encountered: #<RuntimeError: All but one formatter must use --out, only one can print to each stream (or STDOUT)>" error.
And here you can notice
that "rerun" formatter redirects output to rerun.txt
Your cucumer.yml may be
Future RubyMine builds will allow you to use cucumber's "rerun" feature. If you don't want to keep "rerun" behaviour - just use
or
Excellent, excellent explanation, Roman. Thank you.
Exception encountered: #<Errno::ENOENT: No such file or directory - Teamcity::Cucumber::Formatter>
backtrace:
I finally fixed this Issue, thanks to this post:
https://rspec.lighthouseapp.com/projects/16211/tickets/597-cucumber-fails-when-tests-are-launched-from-rubymine-using-spork
EDIT cucumber.yml
not working
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: --drb <%= std_opts %>
featureswip: --drb --tags @wip:3 --wip features
rerun: --drb <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
working
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: --drb <%= std_opts %>
wip: --drb --tags @wip:3 --wip features
rerun: --drb <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
Tested with:
Rails 3.0.6
1. spork-0.8.4
2. spork-0.9.0.rc5
cucumber-rails (0.4.1)
Caution:
rails g cucumber:install generates it with the option "features"
So you only have to remove this word and voilà!
Thank you for the investigation and workaround!
By the way, I'm using a cucumber.yml generated by cucumber 0.10.2 and cucumber+spork works out of the box. My cucumber.yml:
That doesn't run with the drb service though --- no '--drb' in the command line.
I'm trying to get Cucumber working with Spork at the moment, and not having much joy. I'll just give up for the time being. :|
Geoff,
Which cucumber gem version do you use?