运行功能时不会自动加载 Cucumber 步骤

发布于 2024-08-28 08:11:19 字数 573 浏览 5 评论 0原文

我最近更新了我机器上的 Cucumber gems(“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”文件似乎也没有被加载。

如果有人遇到过此问题或知道为什么会发生这种情况,我们将不胜感激。

谢谢。

I have recently updated the Cucumber gems ('cucumber' and 'cucumber-rails') on my machine and have run into a couple of issues. The one i am currently fighting is that none of the defined steps for my features are being automatically loaded by Cucumber. This results in my command line telling me i "can implement step definitions for undefined steps with these snippets" for every single step i use in my features.

I have run:

cucumber --verbose

...and can see the following:

Code:
* vendor/plugins/paperclip/cucumber/paperclip_steps.rb

However, none of the steps are being loaded in by Cucumber unless i specify files to load:

cucumber -r features/step_definitions/web_steps.rb

I thought this might just be the custom step files i had created within the "step_definitions" folder in my app structure but it would appear the standard "web_steps" file isnt being loaded either.

Would appreciate hearing from anyone who has come across this issue or knows why this might be happening.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

两相知 2024-09-04 08:11:19

您可以将 -r feature 包含到 cucumber.yml 文件中,以便 cucumber 加载 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

You can include -r feature into your cucumber.yml file such that cucumber loads all the step definitions in feature/ directory. Append above in std_opts. See appended cucumber.yml file below.

 <%
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
三生殊途 2024-09-04 08:11:19

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

我现在可以运行我的测试:

cucumber --no-profile

OK i have come up with a solution for this for the time being. Im not sure if its the right one or not. Simple disabling profiles when running the cucumber command seems to ensure that the correct step definitions are loaded for the features.

I can now run my tests with:

cucumber --no-profile
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文