当运行单个功能时,黄瓜无法找到步骤 [英] Cucumber can't find steps when running a single feature
问题描述
我刚刚安装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 / 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标志来明确指出黄瓜在它运行您的功能之前包括什么。例如:
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
这篇关于当运行单个功能时,黄瓜无法找到步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!