“耙”运行我所有的黄瓜测试罚款,但“黄瓜”没有步骤

问题描述:

我已经继承了一个Rails(3)应用程序,并试图抓住现有的黄瓜测试。我有在应用程序的“功能”文件夹下面的设置(我已经错过了这是不相关的任何文件,如额外的功能和步骤)“耙”运行我所有的黄瓜测试罚款,但“黄瓜”没有步骤

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

如果我运行“耙”,那么它运行feature/people/new-person.feature中的所有功能,正确使用step_definitions中列出的步骤。

但是,我不想每次运行耙子,因为它需要很长时间,我只想在黄瓜中运行特定的测试,例如, cucumber features/people/new-person.feature -l 8

当我这样做,它运行该功能,但尚未加载的步骤。我回来了:

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. 

为什么不是黄瓜加载的步骤?我猜想我需要在某个地方需要步骤,但我无法弄清楚在哪里。

谢谢,最大

+0

对于参数的缘故将特征文件移动到一个目录中。我在我的各种.feature文件中没有任何地方需要,我没有看到任何配置goop在功能/支持/文件,似乎指向这一点。你确定你的people_steps.rb代码是功能性的吗?你有没有牺牲一只鸡? – jaydel 2011-06-07 12:32:16

+0

@jaydel - 这一切工作正常,当我只用'耙子',即步骤都加载罚款。我想继续追求我的特色,只是为了将他们组织成合理的团体。 – 2011-06-07 14:34:40

+0

@jaydel - 但是,将功能文件移动到主要功能文件夹确实解决了问题...必须有一个需要某处,我需要添加额外的“../”我估计。 – 2011-06-07 14:37:12

马克斯·威廉姆斯找到了答案,他的问题:

编辑 - 找到了答案,在这里:https://rspec.lighthouseapp.com/projects/16211/tickets/401-envrb-not-loaded-when-running-individual-features-in-sub-directories

在配置/ cucumber.yml有一条线,看起来像这样:

std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags [email protected]"

将其更改为

std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags [email protected] --require features/"

这就像在您的黄瓜测试运行结束时添加--require features/并使其正确加载一切。

+0

谢谢Sebastien :) – 2011-06-09 08:37:27

+0

@Max,你应该接受这个答案。 – nessur 2011-07-14 18:06:46

+0

另外,如果您不想添加默认选项,则可以在运行时将'-r features /'添加到黄瓜。 – nessur 2011-07-14 18:07:42

我没有一个cucumber.yml文件来改变,无论出于何种原因。因此,只需创建一个空白的/config/cucumber.yml文件并将该行放入其中:

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

没有工作。 (这并不奇怪,我觉得那里应该是比只是一条线更多了。)

我发现了一个完整的,工作,cucumber.yml示例文件在这里的一个很好的例子:http://jdfrens.blogspot.com/2010/03/uh-yes-i-did-define-that-cucumber-step.html