Ruby 如何选择不运行cucumber功能

Ruby 如何选择不运行cucumber功能,ruby,cucumber,Ruby,Cucumber,如果我在windows上,我不想运行某些Cumber功能。谷歌和cucumber文档在这里看起来非常吸引人 谢谢 最好的方法可能是使用标签 例如,如果向某个功能添加一个类似于@not windows的标记,则可以自定义cucumber执行以忽略此项 @not-windows Feature: Your feature that causes a problem your scenarios 如果然后使用cucumber--tags~@not windows运行测试,它将运行所有未被@not

如果我在windows上,我不想运行某些Cumber功能。谷歌和cucumber文档在这里看起来非常吸引人


谢谢

最好的方法可能是使用标签

例如,如果向某个功能添加一个类似于
@not windows
的标记,则可以自定义cucumber执行以忽略此项

@not-windows
Feature: Your feature that causes a problem
  your scenarios
如果然后使用
cucumber--tags~@not windows运行测试,它将运行所有未被@not windows标记的CUKE。~是导致“not”行为的原因,通过执行
cucumber--tags@notwindows
,您只能运行这些标记。在Windows中使用第一行cucumber,您可以阻止有问题的功能(或单个场景)运行,但如果您在另一个操作系统上并且正常运行cucumber,这些功能仍将运行


参考资料:

支持泰勒的答案我想提出以下补充信息:

使用 如果您在多个不同的环境中运行系统,您可能需要创建一个配置文件,然后只需为您定义一个默认配置文件,其中不包括该文件

# config/cucumber.yml
##YAML Template
---
windows: --tags ~@not-windows
default: --tags @not-windows
执行(在非windows系统上/默认)

执行(在windows系统上):

您可以将默认设置为当前所处的任何环境,以避免您必须记住哪些功能不执行;允许您只执行
cumber

使用 创建一个rake任务,该任务检查您的环境并包含您想要的标记:

require 'rubygems'
require 'cucumber'
require 'cucumber/rake/task'

WINDOWS_PLATFORM = /mswin|win32|mingw/ unless defined? WINDOWS_PLATFORM

Cucumber::Rake::Task.new(:features) do |t|
  tags = (RUBY_PLATFORM =~ WINDOWS_PLATFORM ? "~@not-windows" : "@not-windows")
  t.cucumber_opts = "features #{tags}"
end
执行(在任一平台上):

这将根据您的环境自动包含正确的标记

$ cucumber -p windows
require 'rubygems'
require 'cucumber'
require 'cucumber/rake/task'

WINDOWS_PLATFORM = /mswin|win32|mingw/ unless defined? WINDOWS_PLATFORM

Cucumber::Rake::Task.new(:features) do |t|
  tags = (RUBY_PLATFORM =~ WINDOWS_PLATFORM ? "~@not-windows" : "@not-windows")
  t.cucumber_opts = "features #{tags}"
end
$ rake features