繁体   English   中英

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

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

我刚来这地方。 我希望问题的准确性是正确的。 我没有找到答案, 这里也没有解决方案

介绍:

我使用RubyMine中的Ruby / Watir / Cucumber创建了一个Web应用程序的自动化测试。 功能正常-测试通过(步骤定义确定)。 不幸的是,我无法在NetBeans中运行相同的功能。 似乎在将步骤与步骤定义链接时确实存在问题。

使用的相关环境/工具:

Windows 7的
NetBeans IDE 8.0
NenBeans插件:Cetriolo v 1.0
NetBeans插件:Cucumber Features v 1.8.2
Ruby 1.9.3
创业板:watir-webdriver 0.6.10
创业板:黄瓜1.3.15
GEM:页面对象1.0
项目结构:
Picture_of_project_structure


功能看起来像:

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

问题描述:

.. are underlined and there is a comment that there is no step definition for those steps. 在功能文件“ ..”带有下划线,并且注释没有针对这些步骤的步骤定义。
(enabled by plugin): Image_of_step_window_without_step_implementation 在“ 没有看到任何实现(由插件启用): Image_of_step_window_without_step_implementation

is executed. 当我使用Cucumber图标(由插件启用)运行accepting_puppies.feature时执行背景和步骤“ 上执行。 我的意思是-Web浏览器打开并转到正确的地址,然后关闭(这种情况发生4次-4种情况中的每种情况发生一次)。 输出为:

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


当我遵循此答案并使用以下命令在cmd窗口中运行功能时:

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

(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
/.../

问题/要求:

谁能告诉我为什么使用NetBeans无法识别步骤定义? 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. 由于成功执行,并且RubyMine的所有步骤都没有问题,所以我很困惑(特别是因为我对所有这些Ruby / Watir / Cucumber都是陌生的。

我的RubyMine评估在5天内结束,我仍然想学习:)

当我第一次使用它时,在Rubymine中有一个与此类似的问题,解决方案在目录设置中。 步骤定义文件夹位于我的项目中错误的目录树下,因此当它尝试在默认位置找到它们时,什么也没找到。

更具体地说,我的step_definition文件夹是在功能文件夹中的主项目目录INSTEAD下创建的。 因此,当红宝石试图找到一个名为step_definitions的文件时,它在相对文件(功能)中找不到,因此告诉我这些步骤未定义,尽管它们显然位于另一个文件夹中。 一旦我移动了文件,它就可以正常工作。

我对netbeans一无所知,但是默认情况下它可能会在与rubymine不同的位置中查找这些步骤定义。

您的文件结构看起来正确,但是对于netbeans是否在其他位置查找步骤定义,我并不熟悉。

你有没有尝试删除黄瓜功能插件的建议在这里在接受的答案下面的答案?

如果那不起作用,请查看您是否可以找到默认情况下netbeans在哪里查找其step_definitions文件夹。

暂无
暂无

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

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