简体   繁体   English

Netbeans中的Ruby Watir和Cucumber-方案未定义

[英]Ruby Watir and Cucumber in Netbeans - scenario undefined

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. 我使用RubyMine中的Ruby / Watir / Cucumber创建了一个Web应用程序的自动化测试。 Feature works fine - the test is passed (steps definitions are OK). 功能正常-测试通过(步骤定义确定)。 Unfortunately I cannot run the same feature in NetBeans. 不幸的是,我无法在NetBeans中运行相同的功能。 It seems like I do have problem with linking steps with their steps definitions. 似乎在将步骤与步骤定义链接时确实存在问题。

Relevant environment/tools used: 使用的相关环境/工具:

Windows 7 Windows 7的
NetBeans IDE 8.0 NetBeans IDE 8.0
NenBeans plugin: Cetriolo v 1.0 NenBeans插件:Cetriolo v 1.0
NetBeans plugin: Cucumber Features v 1.8.2 NetBeans插件:Cucumber Features v 1.8.2
Ruby 1.9.3 Ruby 1.9.3
GEM: watir-webdriver 0.6.10 创业板:watir-webdriver 0.6.10
GEM: cucumber 1.3.15 创业板:黄瓜1.3.15
GEM: Page-object 1.0 GEM:页面对象1.0
Project structure: 项目结构:
Picture_of_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 在“ 步骤”窗口中没有看到任何实现(由插件启用): 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. 当我使用Cucumber图标(由插件启用)运行accepting_puppies.feature时,将执行背景和步骤“ 领取我”,并在收养站点上执行。 I mean - web browser opens and goes to the correct address and then closes (this happens 4 times - once for every of 4 scenarios). 我的意思是-Web浏览器打开并转到正确的地址,然后关闭(这种情况发生4次-4种情况中的每种情况发生一次)。 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: 当我遵循此答案并使用以下命令在cmd窗口中运行功能时:

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): 结果是相同的(浏览器已打开,页面已访问,浏览器已关闭),但至少我可以看到accepting_puppy_steps.rb被“使用” (输出是相同的,但是在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? 谁能告诉我为什么使用NetBeans无法识别步骤定义? 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. 由于'Given'成功执行,并且RubyMine的所有步骤都没有问题,所以我很困惑(特别是因为我对所有这些Ruby / Watir / Cucumber都是陌生的。

My RubyMine evaluation ends within 5 days and I still want to learn :) 我的RubyMine评估在5天内结束,我仍然想学习:)

I had an issue similiar to this in Rubymine when I was first using it and the solution was in the directory setup. 当我第一次使用它时,在Rubymine中有一个与此类似的问题,解决方案在目录设置中。 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. 更具体地说,我的step_definition文件夹是在功能文件夹中的主项目目录INSTEAD下创建的。 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. 因此,当红宝石试图找到一个名为step_definitions的文件时,它在相对文件(功能)中找不到,因此告诉我这些步骤未定义,尽管它们显然位于另一个文件夹中。 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. 我对netbeans一无所知,但是默认情况下它可能会在与rubymine不同的位置中查找这些步骤定义。

Your file structure looks correct, but I am not familiar if netbeans looks in a different place for the step definitions or not. 您的文件结构看起来正确,但是对于netbeans是否在其他位置查找步骤定义,我并不熟悉。

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. 如果那不起作用,请查看您是否可以找到默认情况下netbeans在哪里查找其step_definitions文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM