2

I am new here. I hope that question precision will be right. I did not found the answer neither here nor this solution helped.

Introduction:

I have created an automated test of web app using Ruby/Watir/Cucumber in RubyMine. Feature works fine - the test is passed (steps definitions are OK). Unfortunately I cannot run the same feature in NetBeans. It seems like I do have problem with linking steps with their steps definitions.

Relevant environment/tools used:

Windows 7
NetBeans IDE 8.0
NenBeans plugin: Cetriolo v 1.0
NetBeans plugin: Cucumber Features v 1.8.2
Ruby 1.9.3
GEM: watir-webdriver 0.6.10
GEM: cucumber 1.3.15
GEM: Page-object 1.0
Project structure:
Picture_of_project_structure


Feature looks like:

 1    Feature: Adoptin Puppies
 2    
 3      As a puppy lover
 4      I want to adopt puppies
 5      So they can chew my furniture
 6    
 7     Background:
 8       Given I an on the adoption site
 9    
10     Scenario: Adopting one puppy
11       When I click the View Details of puppy 1 button
12       And I click the Adopt Me button
13       And I click the Complete the Adoption button
/..../

Problem description:

In the feature file Given, When, And, And,.. are underlined and there is a comment that there is no step definition for those steps.
There is no implementations seen in the Steps window (enabled by plugin): Image_of_step_window_without_step_implementation

When I run the adopting_puppies.feature using Cucumber icon (enabled by plugin) then Background and step Given I an on the adoption site is executed. I mean - web browser opens and goes to the correct address and then closes (this happens 4 times - once for every of 4 scenarios). The output is:

Output of running [cmd, /C, cucumber, -r, C:\Users\t4f\NetBeansProjects\test_puppies_copy\lib\features, C:\Users\t4f\NetBeansProjects\test_puppies_copy\lib\features\adopting_puppies.feature, -s] is:
--- START ---

*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
Feature: Adoptin Puppies

  As a puppy lover
  I want to adopt puppies
  So they can chew my furniture

  Background: 
    Given I an on the adoption site
      dupa

  Scenario: Adopting one puppy
    When I click the View Details of puppy 1 button
    And I click the Adopt Me button

 /...steps written here like in feature file.../

4 scenarios (4 undefined)
43 steps (30 skipped, 9 undefined, 4 passed)
2m35.034s

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

When(/^I click the View Details of puppy (\d+) button$/) do |arg1|
  pending # express the regexp above with the code you wish you had
end


When I follow this answer and run the feature in cmd window using:

cucumber lib/features/adopting_puppies.feature -r lib/features

the result is the same (browser opened, page visited, browser closed) but at least I can see that adopting_puppy_steps.rb is 'used' (output is the same, but there are comments after each line of otuput):

/.../
  Background:                       # lib\features\adopting_puppies.feature:7
    Given I an on the adoption site # lib/features/step_definitions/adopting_pup
py_steps.rb:1
      dupa

  Scenario: Adopting one puppy                            # lib\features\adoptin
g_puppies.feature:10
    When I click the View Details of puppy 1 button       # lib\features\adoptin
g_puppies.feature:11
    And I click the Adopt Me button                       # lib/features/step_de
finitions/adopting_puppy_steps.rb:17
/.../

Question/request:

Can anyone, please, tell me why with NetBeans the step definitions cannot be recognized? Since 'Given' is executed successfuly, and RubyMine does not have problems with all the steps, I am confused (especially cause I am new to all this Ruby/Watir/Cucumber stuff.

My RubyMine evaluation ends within 5 days and I still want to learn :)

Community
  • 1
  • 1

1 Answers1

0

I had an issue similiar to this in Rubymine when I was first using it and the solution was in the directory setup. The step definitions folder was under the wrong directory tree in my project, so when it was trying to find them in the default location, it found nothing.

More specifically, my step_definition folder was created under my primary project directory INSTEAD of inside my feature file folder. So when rubymine tried to find a file called step_definitions, it looked in the relative file(feature) didnt find one, so it was telling me the steps were not defined, though they clearly were in another folder. Once i moved the file, it worked fine.

I dont know anything about netbeans, but it MAY be looking in a different location than rubymine by default to find those step definitions.

Your file structure looks correct, but I am not familiar if netbeans looks in a different place for the step definitions or not.

Did you try removing the Cucumber features plugin as suggested here in the answer below the accepted answer?

If that doesnt work, see if you can find out where netbeans looks for its step_definitions folder by default.

Community
  • 1
  • 1
Mayshar
  • 190
  • 7
  • Thanks for noticing. I tried removing the Cucumber Feature plugin leaving only Cetriolo and beahviour is the same (steps are not linked, underline is seen). --- Something tricky is happening here (not editing the question since this is other problem): 4 scenarios include the same steps with different data. Today feature goes beyond opening browser and visiting site. But every run has got a different result - the same step can fail in scenario one and pass in scenario two (unable to locate element, seems like Watir looks for it too early). Non deterministic. – user3673885 Jun 16 '14 at 18:53
  • Yes, that has to do with watir trying to do stuff before the page fully renders. You can avoid that by using object.wait_until_present, that way it will wait until your element is present before doing whatever action. As for your question, did you try to find the directory structure for netbeans? see if its different than rubymine? – Mayshar Jun 17 '14 at 12:11
  • Thank You for the support! I do have exactly the same folder structure from 'features' down. What differs is above: Ruby: 'project/features', NetBeans: 'project/lib/features'.
    Check out what has happened when I copied some other feature using the same steps: [Two_features](http://s24.postimg.org/g6xasyoo5/two_files.png). Test_puppies got the Navigator content and is underlined. Adopting_puppies_with_checking_shopping_card does not have Navigator content (not seen on the picture), but WORKS! There are no differences I can find, but will sit on this issue during the weekend.
    – user3673885 Jun 19 '14 at 10:26