运行单个功能时黄瓜找不到步骤找不到、黄瓜、步骤、功能

由网友(不见你会想。)分享简介:我刚刚将 cucumber 安装到一个新的 rails 项目中(第一次从头开始设置),它在运行所有测试时运行良好(bundle exec cucumber)但找不到任何我运行单个功能文件时的步骤.我该如何开始调试呢?I've just installed cucumber into a new rails proje...

我刚刚将 cucumber 安装到一个新的 rails 项目中(第一次从头开始设置),它在运行所有测试时运行良好(bundle exec cucumber)但找不到任何我运行单个功能文件时的步骤.我该如何开始调试呢?

I've just installed cucumber into a new rails project (first time setting it up from scratch) and it works wonderfully when running all tests (bundle exec cucumber) but can't find any of my steps when I run a single feature file. How might I start to debug this?

rails (3.2.13)
cucumber-rails (1.3.1)
cucumber (>= 1.2.0)

# file listing
features/
├── campaigns
│   ├── donating_campaigns.feature
│   └── viewing_campaigns.feature
├── step_definitions
│   └── campaign_steps.rb
└── support
    └── env.rb

推荐答案

它只会在 features 目录树中查找同级或更低级别的文件.因此,如果您尝试仅运行 features/campaigns/donating_campaigns.feature 中的场景,它将找不到 step_definitions 目录.

It will only find files at the same level or lower in the features directory tree. So if you try to run just the scenarios in features/campaigns/donating_campaigns.feature it cannot find the step_definitions directory.

您可以使用 --require 标志明确告诉 cucumber 在运行您的功能之前要包含什么.例如:

You can use the --require flag to explicitly tell cucumber what to include before it runs your feature. For example:

bundle exec cucumber --require features/step_definitions features/campaigns/donating_campaigns.feature
阅读全文

相关推荐

最新文章