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?
请先登录再写评论。
The simplest way to run cucumber test using RubyMine GUI test runner is to launch *.feature file from console

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
In case of Rake task - please open rake tasks settings (RubyMine | Run | Edit Configurations...) and check "Cucumber" checkbox in attached test frameworks list

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".

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.
Found the issue.
The default run configuration for Cucumber was missing some environment variables. Here is where I ended up.
config/cucumber.yml
lib/tasks/cucumber.rake
And then in RM > Run > Edit Configurations > Defaults > Cucumbers, set the following environment variables.
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.