Cucumber 场景失败且没有错误消息

发布于 2024-09-07 23:36:40 字数 2007 浏览 5 评论 0原文

我正在我的 Mac OS X 机器上安装 Rails 和 Cucumber。当我尝试运行以下场景时:

Feature: ActorDetail
  In order to learn about an actor
  As a costumer 
  I want to see their details

Scenario: Actors page should exist
Given I am on actor page
Then I should see "Actors"

当我尝试运行测试时,我得到以下信息:

kevin:11:17 PM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning:     Gem::Dependency#version_requirements is deprecated and will be removed on or after August     2010.  Use #requirement
F--F

Failing Scenarios:
cucumber features/ActorDetail.feature:6 # Scenario: Actors page should exist

1 scenario (1 failed)
2 steps (2 skipped)
0m0.138s

这是一个失败的测试,但不是我希望它失败的方式,如果您知道我的意思的话。我期待一条消息告诉我没有为“Actors”定义路径

有趣的是,如果我将“Actors”周围的双引号更改为单引号,这就是我得到的结果:

kevin:11:09 PM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
F-UF

Failing Scenarios:
cucumber features/ActorDetail.feature:6 # Scenario: Actors page should exist

1 scenario (1 failed)
2 steps (1 skipped, 1 undefined)
0m0.144s

如果我提供的信息不足,我深表歉意我已经安装的 gems、配置等。到目前为止,我已经在 Rails 中开发了大约三个小时。

非常感谢,

KevDog

更新 我做了一次宝石更新,现在事情似乎变得更糟了。这是当前的错误:

kevin:12:29 AM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
/Users/kevin/.gem/ruby/1.8/gems/nokogiri-1.4.2/lib/nokogiri/nokogiri.bundle: [BUG] Bus Error
ruby 1.8.7 (2008-05-31 patchlevel 0) [i686-darwin9.4.0]

Abort trap

听起来一点都不好。

I'm getting Rails and Cucumber going on my Mac OS X box. When I try to run the following scenario:

Feature: ActorDetail
  In order to learn about an actor
  As a costumer 
  I want to see their details

Scenario: Actors page should exist
Given I am on actor page
Then I should see "Actors"

When I attempt to run the tests I get the following:

kevin:11:17 PM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning:     Gem::Dependency#version_requirements is deprecated and will be removed on or after August     2010.  Use #requirement
F--F

Failing Scenarios:
cucumber features/ActorDetail.feature:6 # Scenario: Actors page should exist

1 scenario (1 failed)
2 steps (2 skipped)
0m0.138s

Which is a failing test, but not the way I would like it to fail, if you know what I mean. I was expecting a message telling me that there wasn't a path defined for "Actors"

Interestingly, if I change from double to single quotes around "Actors", this is what I get:

kevin:11:09 PM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
F-UF

Failing Scenarios:
cucumber features/ActorDetail.feature:6 # Scenario: Actors page should exist

1 scenario (1 failed)
2 steps (1 skipped, 1 undefined)
0m0.144s

I apologize if I am providing insufficient information on what gems I have installed, config, etc. I've been developing in Rails for about three hours so far.

Many thanks,

KevDog

Update
I did a gem update, and now things seem to have gotten worse. This is the current error:

kevin:12:29 AM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
/Users/kevin/.gem/ruby/1.8/gems/nokogiri-1.4.2/lib/nokogiri/nokogiri.bundle: [BUG] Bus Error
ruby 1.8.7 (2008-05-31 patchlevel 0) [i686-darwin9.4.0]

Abort trap

That doesn't sound good at all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我爱人 2024-09-14 23:36:40

使用下面的命令来运行你的黄瓜功能,这将给出详细的输出。

cucumber --format pretty

use below command to run your cucumber features this will give verbose output.

cucumber --format pretty
一场春暖 2024-09-14 23:36:40

对于 Gem::Dependency#version_requirements is deprecated 警告,您似乎需要升级 Rails(至少到 2.3.6)。 Rails 2.3.6 和 2.3.7 都包含修复您看到的警告的提交。我不确定为什么你的 gem 更新不会解决这个问题,除非它只是尝试更新你的主目录中的 gem(我没有尝试使用每用户 GEM_HOME,所以我不确定它会如何交互需要安装系统 gem 目录中包含的较新版本的 gems)。也许您需要执行 sudo /usr/local/bin/gem update 而不是您之前运行的任何更新(请务必移到一边或删除您的主 gems 目录中损坏的 nokogiri 安装)。

Then I should see 步骤中使用单引号和双引号时结果的差异可能是因为没有与单引号版本匹配的步骤定义。检查您的features/step_definitions/web_steps.rb 文件以验证这一点(我的 Cucumber 0.8.0 版本包括 JSON 变体、双引号分隔变体(文字字符串)和斜杠分隔变体(正则表达式)匹配)但没有单引号变体)。

此外,您可能需要使用actor页面而不是actor页面,或者在features/中定义actor页面的路径映射支持/paths.rb。

For the Gem::Dependency#version_requirements is deprecated warning, it looks like you need to upgrade Rails (to at least 2.3.6). Both Rails 2.3.6 and 2.3.7 include a commit that fixes the warning you are seeing. I am not sure why your gem update would not have addressed this unless it is because it is only trying to update the gems in your home directory (I have not tried using a per-user GEM_HOME, so I am not sure how it would interact with needing to install newer versions of gems that are included in the system gem directory). Maybe you need to do sudo /usr/local/bin/gem update instead of whatever update you previously ran (be sure to move aside or delete the broken nokogiri installation in your home gems directory, too).

The difference in the results when using single and double quotes in your Then I should see step is probably due to the fact that there is no step definition that matches the single quoted version. Check your features/step_definitions/web_steps.rb file to verify this (my version from Cucumber 0.8.0 includes a a JSON variant, a double quote delimited variant (literal string), and a slash delimited variant (regexp match) but no single quoted variant).

Also, you may need to use the actor page instead of actor page, or define a path mapping for actor page in features/support/paths.rb.

闻呓 2024-09-14 23:36:40

您是否尝试过这样做:

rake gems:install RAILS_ENV=test

这应该安装测试环境所需的所有 gem。
此外,根据您是否定义了任何模型,您可能还需要准备测试数据库

rake db:test:prepare

Have you tried doing:

rake gems:install RAILS_ENV=test

This should install all the gems the test environment required.
Also, depending on whether you have any models defined yet, you may also need to prepare the test database with

rake db:test:prepare
◇流星雨 2024-09-14 23:36:40

检查空格。在您发布的示例中,它没有正确缩进。

Feature: ActorDetail
 In order to learn about an actor
 As a costumer 
 I want to see their details

 Scenario: Actors page should exist
   Given I am on actor page
   Then I should see "Actors"

Check the whitespace. In your posted example it is not properly indented.

Feature: ActorDetail
 In order to learn about an actor
 As a costumer 
 I want to see their details

 Scenario: Actors page should exist
   Given I am on actor page
   Then I should see "Actors"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文