Ruby on Rails:Cucumber:我如何 Rake 单个功能?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3097817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 22:48:46  来源:igfitidea点击:

Ruby on Rails: Cucumber: how do I Rake a single feature?

ruby-on-railscucumber

提问by NullVoxPopuli

Reason why I want to run them individually, is because I need to have them individually set up in my Rake file, because, My Java Heap Space fills up when I run them all together

我想单独运行它们的原因是因为我需要在我的 Rake 文件中单独设置它们,因为当我一起运行它们时,我的 Java 堆空间会填满

回答by Ryan Bigg

The correct way is to run it using the cucumberexecutable if you're using Rails 2, or bundle exec cucumberif you're using Rails 3 (and thus Bundler).

cucumber如果您使用的是 Rails 2,或者bundle exec cucumber您使用的是 Rails 3(以及 Bundler),则正确的方法是使用可执行文件运行它。

To run a specific feature:

要运行特定功能:

[command] features/signing_in.feature

To run a specific scenario from that feature:

要从该功能运行特定场景:

[command] features/signing_in.feature:6

The line number can be any line inside that feature, but is usually the first line.

行号可以是该要素内的任何行,但通常是第一行。

If you run rake cucumber:okand some scenarios fail, at the bottom of the output you will see something like this:

如果您运行rake cucumber:ok并且某些场景失败,在输出的底部您将看到如下内容:

cucumber features/sigining_in.feature:6 # Signing in via form

You can triple-click this line and paste it into your terminal to just run that scenario.

您可以三次单击此行并将其粘贴到您的终端中以运行该场景。

回答by Bryan Ash

To answer the Rake question directly, you can use:

要直接回答 Rake 问题,您可以使用:

rake FEATURE=features/adding_products.feature cucumber

but the Using Rakewiki page advises against using rake for anything but on a CI server because it's slower to start. Just use the cucumber command line instead, i.e.:

但是使用 Rakewiki 页面建议不要在 CI 服务器上使用 rake,因为它启动速度较慢。只需使用黄瓜命令行,即:

cucumber features/adding_products.feature

or, if you must:

或者,如果您必须:

bundle exec cucumber features/adding_products.feature

回答by Siddhartha Mukherjee

The rake did not worked for me. Just replaced the rake with bundle exec, and it worked. below is a sample.

耙子对我不起作用。刚刚用 bundle exec 替换了耙子,它起作用了。下面是一个示例。

bundle exec cucumber features/users/signup.feature --require features

捆绑执行黄瓜功能/用户/signup.feature --require 功能

回答by Alper Karap?nar

I'm not sure cucumber's tag featurewas available when the question asked, but i prefer setting @activetag

我不确定在提问时黄瓜的标签功能是否可用,但我更喜欢设置@active标签

  @active
  Feature ..

or

或者

  @active
  Scenario ..

and

  cucumber --tags @active

回答by Robert

I like the short command $ cucumber -n.

我喜欢简短的命令$ cucumber -n

If:

如果:

Feature: Manage Contents
  In order to manage instances from custom content types
  …

Then:

然后:

$ cucumber -n "Manage Contents"

回答by Aravin

To run a single feature file.

运行单个功能文件。

cucumber /project folder/features/featurefile.feature

To run particular scenario:

运行特定场景:

cucumber /project folder/features/featurefile.feature:10

where 10 is the line of scenario.

其中 10 是场景线。

If you use bundler,

如果您使用捆绑器,

bundle exec cucumber /project folder/features/featurefile.feature

bundle exec cucumber /project folder/features/featurefile.feature

回答by theIV

You can use script/cucumberto do individual files.

你可以用script/cucumber做单个文件。

Assuming you are in the root directory of your project and you have a features folder:

假设您在项目的根目录中,并且有一个 features 文件夹:

./script/cucumber features/adding_products.feature

Edit: After re-reading your question, are you looking to do individual features, or scenarios?

编辑:在重新阅读您的问题后,您是要制作单个功能还是场景?

回答by Peter Tillemans

If you use cuke4duke you can run this separately from ant or maven.

如果您使用 cuke4duke,您可以将它与 ant 或 maven 分开运行。

The manualstates that you can use the same options as cucumber. So I would expect you can pas the filename of the feature you want to run on the commandline.

手动状态,您可以使用相同的选项黄瓜。因此,我希望您可以传递要在命令行上运行的功能的文件名。

回答by machzqcq

The parameters generally required when you have multiple cucumber projects in a large scale enterprise are 1) where to run the tests 2) Which environment to run against 3) Which browser 4) What tags

当你在大型企业有多个黄瓜项目时,通常需要的参数是 1) 在哪里运行测试 2) 运行环境 3) 哪个浏览器 4) 什么标签

Below is a pattern that is very flexible and can be used in multiple ways based on your needs. This pattern can be used to run locally, against a selenium grid, against saucelabs and in a continuous integration environment

下面是一个非常灵活的模式,可以根据您的需要以多种方式使用。此模式可用于在本地、针对 selenium 网格、针对酱汁实验室和在持续集成环境中运行

http://seleniumframework.wordpress.com/2014/05/18/pattern-for-running-multiple-cucumber-projects-on-ci-server/

http://seleniumframework.wordpress.com/2014/05/18/pattern-for-running-multiple-cucumber-projects-on-ci-server/