【问题标题】:Running single cucumber feature doesn't load step definitions运行单个黄瓜功能不会加载步骤定义
【发布时间】:2010-11-11 19:56:47
【问题描述】:

我在 features/object/create_object.feature 有一个黄瓜功能。当我使用“黄瓜”命令执行所有功能时,它就会通过。我正在尝试使用这些命令自行执行此功能:

cucumber features/object/create_object.feature
rake features FEATURE=features/object/create_object.feature

但是,此功能的所有步骤定义都未定义:

Using the default profile...
-------UUUUUUUUUUUU

我也尝试使用“--no-profile”禁用配置文件,但无济于事。提前致谢!

【问题讨论】:

    标签: ruby-on-rails cucumber


    【解决方案1】:

    我认为您需要告诉黄瓜在./features的子目录中运行功能时如何定位步骤定义:

    rake features FEATURE=features/object/create_object.feature REQUIRE=features

    根据您的示例在命令行中使用cucumber 对我不起作用——我必须添加--require

    cucumber --require features features/object/create_object.feature

    this blog post 中的更多信息。

    【讨论】:

    • --要求直截了当。谢谢!
    • 为什么它不检查“功能”目录的存在并自动执行此操作,就像 rspec 对“规格”目录所做的那样?
    【解决方案2】:

    更好的方法是将您添加的 -r features 更新到 cucumber.yml 文件。

    Cucumber steps not automatically loaded when running features

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题,但 require 功能没有解决它 相反,我通过使用标签解决了这个问题

      所以不要打电话

      黄瓜功能/accounts.feature

      我打电话

      黄瓜 --tags @account 功能

      “@account”在场景之前的位置

      @current 场景:匿名用户 可以创建一个帐户 给定一个匿名用户

      工作正常。加载所有steps.rb文件

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-01-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多