“耙”运行所有我的黄瓜测试很好,但“黄瓜”没有步骤 [英] "rake" runs all my Cucumber tests fine but "cucumber" doesn't have the steps

查看:116
本文介绍了“耙”运行所有我的黄瓜测试很好,但“黄瓜”没有步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经继承了一个Rails(3)应用程序,我试图抓住现有的Cucumber测试。我在应用程序的功能文件夹中有以下设置(我错过了任何不相关的文件,例如额外的功能和步骤)。

I've inherited a Rails (3) app and am trying to get to grips with the existing Cucumber tests. I've got the following setup in the app's 'features' folder (I've missed out any files which aren't relevant, eg extra features and steps)

/features
  /people
    new-person.feature
  /step_definitions
    people_steps.rb
    web_steps.rb
  /support
    env.rb
    paths.rb
    selectors.rb

如果我运行'rake',它运行features / people / new-person.feature中的所有功能,正确使用step_definitions中列出的步骤。

If I run 'rake' then it runs all the features in features/people/new-person.feature, correctly using the steps listed in step_definitions.

但是,我不想每次都运行rake,因为它需要太长时间,我只想在Cucumber中运行一个特定的测试。 cucumber features / people / new-person.feature -l 8

However, I don't want to run rake every time as it takes too long, I just want to run a specific test in Cucumber, e.g. cucumber features/people/new-person.feature -l 8

但尚未加载步骤。我回来了:

When I do this, it runs the feature but hasn't loaded the steps. I get this back:

Using the default profile...
Feature: Add a new person
  In order to allocate tasks to people
  As a community manager
  I want to add a new person

  Scenario: Secondary navigation should contain "Add new person" # features/people/new-person.feature:8
    Given I am on the new person page                            # features/people/new-person.feature:9
      Undefined step: "I am on the new person page" (Cucumber::Undefined)
      features/people/new-person.feature:9:in `Given I am on the new person page'
    Then I should not see "Add new person"                       # features/people/new-person.feature:10
      Undefined step: "I should not see "Add new person"" (Cucumber::Undefined)
      features/people/new-person.feature:10:in `Then I should not see "Add new person"'

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

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

Given /^I am on the new person page$/ do
  pending # express the regexp above with the code you wish you had
end

Then /^I should not see "([^"]*)"$/ do |arg1|
  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.

为什么Cucumber不会加载步骤?我猜,我需要在某个地方的步骤,但我不能在哪里工作。

Why isn't Cucumber loading the steps in? I'm guessing that I need to require the steps somewhere but I can't work out where.

谢谢,最大

推荐答案

Max Williams找到了他的问题的答案:

Max Williams found the answer to his question:

EDIT - 找到答案, https://rspec.lighthouseapp.com/projects/16211/tickets/401-envrb-not-loaded-when-running-individual-features-in-sub-directories\">https://rspec.lighthouseapp.com/ projects / 16211 / tickets / 401-envrb-not-loaded-when-running-individual-features-in-sub-directories

EDIT - found the answer, here: https://rspec.lighthouseapp.com/projects/16211/tickets/401-envrb-not-loaded-when-running-individual-features-in-sub-directories

在config / cucumber .yml有一行如下所示:

In config/cucumber.yml there's a line that looks like this:

std_opts =--format#{ENV ['CUCUMBER_FORMAT'] ||'pretty' } --strict --tags〜@ wip

将其更改为

std_opts =--format#{ENV ['CUCUMBER_FORMAT'] ||'pretty'} --strict --tags〜@ wip --require features /

这就像在黄瓜测试运行结束时添加 - require features /

This is like adding --require features/ to the end of your cucumber test run and makes it load everything up properly.

这篇关于“耙”运行所有我的黄瓜测试很好,但“黄瓜”没有步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆