How do you get Cucumber Features to run in test framework?

Hey there,

Running v3.1.1 (103.260) and after a little bit of pain i am able to get Cucumber 0.10.2 to work via the Rake Task. IE Tools >> Rake Tasks >> Cucumber. By work, it will fire up the Run panel, show the test spinner on the left, use Capybara / Web Drive and run through all the tests. At the end I have a list of cukes that have failed. Alright perfect.

Now I want to work on one of those cukes. Code a bit and now right click on a scenario and run it. That fires off the following command in the run panel but it does not seem to use the test framework, ie the test spinner on the left shows "No test were found":

/Users/pbaker/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/pbaker/src/sheshin/script/cucumber /Users/pbaker/src/sheshin/features/sign_up.feature --expand --name Home\ page\ should\ have\ sign\ up\ panel --drb --color -r features
Testing started at 4:16 PM ...
Using the default profile...
Disabling profiles...
Feature: Sign Up to Sheshin
  In order to access authorizable content
  As a visitor
  I want create an account and authenticate
  Scenario: Home page should have sign up panel # /Users/pbaker/src/sheshin/features/sign_up.feature:6
    Given I am not authenticated                # features/step_definitions/user_steps.rb:1
    When I am on the home page                  # features/step_definitions/web_steps.rb:44
      Can't find mapping from "the home page" to a path.
      Now, go and add a mapping in /Users/pbaker/src/sheshin/features/support/paths.rb (RuntimeError)
      ./features/support/paths.rb:30:in `rescue in path_to'
      ./features/support/paths.rb:24:in `path_to'
      ./features/step_definitions/web_steps.rb:45:in `/^(?:|I )am on (.+)$/'
      /Users/pbaker/src/sheshin/features/sign_up.feature:8:in `When I am on the home page'
    Then I should see the sign up panel         # /Users/pbaker/src/sheshin/features/sign_up.feature:9
      Undefined step: "I should see the sign up panel" (Cucumber::Undefined)
      /Users/pbaker/src/sheshin/features/sign_up.feature:9:in `Then I should see the sign up panel'
Failing Scenarios:
cucumber /Users/pbaker/src/sheshin/features/sign_up.feature:6 # Scenario: Home page should have sign up panel
1 scenario (1 failed)
3 steps (1 failed, 1 undefined, 1 passed)
0m1.061s
You can implement step definitions for undefined steps with these snippets:
Then /^I should see the sign up panel$/ do
  pending # express the regexp above with the code you wish you had
end
Empty test suite.


Process finished with exit code 1



From the help file, http://www.jetbrains.com/ruby/webhelp/enabling-test-runner-ui-for-cucumber-features.html, it recommends adding "--format Teamcity::Cucumber:Formatter" to the rake file. Since this seems to be running from the cucumber script, not rake, this is a noop. I tried adding it to the default task in cucumber.yml but then I get complaints that it can not find "Teamcity::Cucumber:Formatter". Tried adding it to the Run >> Edit Configurations >> Defaults >> Cucumber >> Runner Options but get that message that it can't find "Teamcity::Cucumber:Formatter".

Any suggestions on how to make cukes run not-from-rake and still get the benefits of RubyMine UI?
5 comments
Comment actions Permalink

The simplest way to run cucumber test using RubyMine GUI test runner  is to launch *.feature file from console
Screen shot 2011-04-12 at 5.53.19 PM.png
Just check that your cucumber gem is mentioned in Gemfile (if you use bundler) or mentioned in list of attached gems in RubyMine | File | Settings | Ruby SDK and Gems

0
Comment actions Permalink

In case of Rake task - please open rake tasks settings (RubyMine | Run | Edit Configurations...) and check "Cucumber" checkbox in attached test frameworks list
Screen shot 2011-04-12 at 5.57.36 PM.png

0
Comment actions Permalink

That does work but the results don't seem to "bind" to RubyMine. IE the test spinner shows "no tests found". This happens if I run individial Scenarios or the entire .feature file. Here is a run where I right clicked on the Scenario in the .feature and followed "Run".

cuke.png

I am assuming that the results from the Run would be listed in the left pane ie all the Cuke's scenarios would be in the left list.

0
Comment actions Permalink

Found the issue.

The default run configuration for Cucumber was missing some environment variables. Here is where I ended up.

config/cucumber.yml

...
default: --drb --strict --tags ~@wip --format Teamcity::Cucumber::Formatter
rake: --drb <%= std_opts %> features

...



lib/tasks/cucumber.rake

...


    Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
      t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
      t.fork = true # You may get faster startup if you set this to false
      t.profile = 'rake'
    end


...


     Cucumber::Rake::Task.new({:rubymine => 'db:test:prepare'}, 'Run features that should pass in rubymine') do |t|
      t.binary = vendored_cucumber_bin
      t.fork = true # You may get faster startup if you set this to false
      t.profile = 'default'
    end


And then in RM > Run > Edit Configurations > Defaults > Cucumbers, set the following environment variables.

RUBYLIB /Applications/RubyMine 3.1.1.app/rb/testing/patch/common:/Applications/RubyMine 3.1.1.app/rb/testing/patch/bdd

CUCUMBER_FORMAT Teamcity::Cucumber::Formatter

TEAMCITY_RAKE_RUNNER_USED_FRAMEWORKS :cucumber     

TEAMCITY_RAKE_RUNNER_MODE idea



cuke_env.png
0
Comment actions Permalink


And then in RM > Run > Edit Configurations > Defaults > Cucumbers, set the following environment variables.

RUBYLIB /Applications/RubyMine 3.1.1.app/rb/testing/patch/common:/Applications/RubyMine 3.1.1.app/rb/testing/patch/bdd
CUCUMBER_FORMAT Teamcity::Cucumber::Formatter
TEAMCITY_RAKE_RUNNER_USED_FRAMEWORKS :cucumber     
TEAMCITY_RAKE_RUNNER_MODE idea

No sense to do it, because RubyMine sets these variables automatically before run configuration execution. They aren't propagated to env.variables settings because it's our internal env variables and there is no need to set them manually or to know about their existence.

0

Please sign in to leave a comment.