运行功能时,黄瓜步骤不会自动加载

时间:2010-04-12 09:31:36

标签: ruby-on-rails testing cucumber

我最近在我的机器上更新了Cucumber宝石('cucumber'和'cucumber-rails')并遇到了几个问题。我目前正在战斗的是,Cucumber没有自动加载我的功能的任何已定义步骤。这导致我的命令行告诉我“我可以为我的功能中使用的每个步骤实现这些片段的未定义步骤的步骤定义”。

我跑了:

cucumber --verbose

...并且可以看到以下内容:

代码:   * vendor / plugins / paperclip / cucumber / paperclip_steps.rb

但是,除非我指定要加载的文件,否则Cucumber不会加载任何步骤:

cucumber -r features/step_definitions/web_steps.rb

我认为这可能只是我在我的应用结构中的“step_definitions”文件夹中创建的自定义步骤文件,但看起来标准的“web_steps”文件也没有被加载。

非常感谢任何遇到过这个问题的人或者知道为什么会发生这种情况。

感谢。

2 个答案:

答案 0 :(得分:12)

您可以将 -r feature 包含到cucumber.yml文件中,以便黄瓜加载feature /目录中的所有步骤定义。在 std_opts 中附加到上方。请参阅下面附加的cucumber.yml文件。

 <%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip -f feature"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip

答案 1 :(得分:2)

好的,我暂时想出了解决方案。我不确定它是否是正确的。运行cucumber命令时简单禁用配置文件似乎可以确保为功能加载正确的步骤定义。

我现在可以用:

运行我的测试
cucumber --no-profile
相关问题