Cucumber run but doesn't work correctly in RubyMine 4

Answered

Hello,
I'm new to Ruby, Cucumber. I have tests that can be run from the Command Prompt, they run Browser and everything work correctly. However when I try to run them through RubyMine the browser doesn't start and the test fails in all steps. Is there something specific with the configuration. I'm selecting Feature -> .feature file.

I would like to Debug the test, that's why I need to run them through RubyMine

Forgot to mention that I'm using RubyMine 4.0.3 with Cucumber 1.2.1

Thank you

12 comments
Comment actions Permalink

Hi,

it is hard to say what is the cause of the problem and how to solve it from the description you provided :(
Could you, please show the output of cucumber (when you execute it in RM) and definition of the first failed step (at least).
Also what OS do you use?

Regards, Oleg.

0
Comment actions Permalink

Hi Oleg,
Thank you for your reply.  I'm using Windows 7 x64,

All my test are located in :
C:\cucumber-tests\admin-tests\

for example:
C:\cucumber-tests\admin-tests\features\My_First_Test
C:\cucumber-tests\admin-tests\features\My_First_Test\My_First_Test.feature
C:\cucumber-tests\admin-tests\features\My_First_Test\features\step_definitions\My_First_Test.rb

When I run this test from the Command Prompt:
C:\cucumber-tests\admin-tests>cucumber features\My_First_Test

2 steps passed and 1 scenario fails

however I cannot see this working. Here is what I have in the feature file:

Feature: My First Test
  This is a Demo Test.

  Scenario: Create user
    Given admin username to login on the site
    When user search by Customer ID
    #Then logout user

I see the following output when I run the test through RubyMine:

C:\Ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:\Ruby193\bin/cucumber C:/cucumber-tests/admin-tests/features/My_First_Test/My_First_Test.feature --color -r features --format pretty
Feature: My First Test
  This is a Demo Test.


  Scenario: Create user                       # C:\cucumber-tests\admin-tests\features\My_First_Test\My_First_Test.feature:4
    Given admin username to login on the site # C:\cucumber-tests\admin-tests\features\My_First_Test\My_First_Test.feature:5
    When user search by Customer ID           # C:\cucumber-tests\admin-tests\features\My_First_Test\My_First_Test.feature:6


1 scenario (1 undefined)
2 steps (2 undefined)
0m0.001s


You can implement step definitions for undefined steps with these snippets:


Given /^admin username to login on the site$/ do
  pending # express the regexp above with the code you wish you had
end


When /^user search by Customer ID$/ do
  pending # express the regexp above with the code you wish you had
end


If you want snippets in a different programming language,
just make sure a file with the appropriate file extension
exists where cucumber looks for step definitions.




Process finished with exit code 0



 
According me something goes wrong with the paths. Or I'm not configuring correctly the Running Configuration.

Thanks in advance

0
Comment actions Permalink

Hello Hristo,

I didn't manage to reproduce the problem. I will appreciate if you provide a simple project. I hope it will help me to sort out and fix the problem.

Thank you.

0
Comment actions Permalink

Hello Andrey,
I cannot send my project because my company's policy doesn't allow it. However it might be helpful if you can point me to a good sample showing a sample test for RubyMine/Cucumber.

I believe that this is cased by the running environment or running configuration.

Regards
Hristo

0
Comment actions Permalink

Usually RubyMine works well with standart cucumber folder layout:


the "features" folder contains set of .feature files
the "features/step_definitions" folder contains set of Ruby files with step definitions.

Also I attached a simple project with properly located cucumber files.



Attachment(s):
cucumber-tests.zip
0
Comment actions Permalink

Andrey,
thank you for the attached sample. I was able to create and run the test under RubyMine.

I will try to figure this out.

Thanks for your help

0
Comment actions Permalink

I'm having the some issue with running cucumber tests thru RubyMine as well. They work when I run them in the Terminal.

I've downloaded the sample project and set up the Run configuration to run the test but Ruby can't seem to find the step file. Any suggestions?

Here are some screen shots.



Attachment(s):
Test_Configuration.png
0
Comment actions Permalink

Blia,
I'm still not able to resolve this, maybe I will look into this next week but mention that the issue is cased by the confiuration file (cucumber.yml) where we set the development, stage and production environment. If I remove it and use simple test everything seems to work as expected.

0
Comment actions Permalink

Hi Andrey,

I downloaded the sample file that you provided and nested the step file into another folder and it works. However, when I create cucumber project with the same structure, it does not work properly. Is it a bug?

Getting a little frustrated here...

I've attached my sample project.



Attachment(s):
TestCuke2.zip
0
Comment actions Permalink

Blia,

The difference in cucumber's behavior in RubyMine and in console is explained by working directory. When you run cucumber from Console you are in “TestCuke2”, but when you are trying to run cucumber tests in directory “TestCuke2/features/buiding” from RubyMine it creates Run Configuration with default value of working directory (the value is “TestCuke2/features/buiding”). You should set working directory as full path to TestCuke2 directory (in my case it would be “C:\Users\andrey.vokin\Downloads\TestCuke2”)



Thank you
0
Comment actions Permalink

That helps alot. I got it working now. Thanks!

0
Comment actions Permalink

stumbled across this article. still very helpful. thanks @Andrey

0

Please sign in to leave a comment.