你如何让 cucumber/guard 过滤像@wip 这样的标签? [英] How do you get cucumber/guard to filter on tags like @wip?

查看:13
本文介绍了你如何让 cucumber/guard 过滤像@wip 这样的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 spork 和 guard,并且我的 RSpec 测试运行良好,所有这些测试都运行正确.为了加快测试速度,我可以使用放置在 .rspec 文件中的标签成功过滤 RSpec 测试.

I'm running spork and guard and all has been going very well with my RSpec tests which were all run correctly. In order to speed up the tests I could successfully filter my RSpec tests with tags I placed in my .rspec file.

.rspec

--colour
--debug
--tag focus
--tag now

很遗憾,虽然我无法过滤我的黄瓜标签.每次 cucumber 运行时,它都会运行 everything 或仅运行已更改的文件.

Unfortunately though I have not been able to filter my cucumber tags. Every time cucumber runs it runs either everything or just the file that changed.

如何让 cucumber/spork/guard 尊重 @wip、@now 等标签并只运行这些测试?是否有一些相当于黄瓜标签的 .rspec 文件?

How can I get cucumber/spork/guard to respect tags like @wip, @now etc and run only those tests? Is there some equivalent to the .rspec file for cucumber tags?

推荐答案

您可以使用黄瓜配置文件来定义要执行的标签.使用 YML 文件,您可以定义执行 @wip 标签的配置文件:

You could use a cucumber profile to define the tags that you want to execute. Using the YML file, you can define a profile that execute your @wip tags:

wip: --tags @wip

更多信息请访问:

https://github.com/cucumber/cucumber/wiki/cucumber.yml

你也可以从命令行运行 cucumber 并传递 -t 参数:

You can also just run cucumber from the command line and pass it the -t argument:

cucumber -t @wip,@now

来自帮助(黄瓜 -h):

From the help (cucumber -h):

只执行标签匹配的功能或场景TAG_EXPRESSION.场景继承在功能级别上声明的标签.最简单的TAG_EXPRESSION 只是一个标签.示例:--tags @dev.当标签中的标签表达式以 ~ 开头,这表示布尔 NOT.示例:--tags ~@dev.一个标签表达式可以有多个标签,用逗号隔开,表示逻辑或.示例:--tags @dev,@wip.可以指定 --tags 选项几次,这表示逻辑与.示例:--tags @foo,~@bar --tags @zap.这表示布尔表达式 (@foo || !@bar) &&@zap

Only execute the features or scenarios with tags matching TAG_EXPRESSION. Scenarios inherit tags declared on the Feature level. The simplest TAG_EXPRESSION is simply a tag. Example: --tags @dev. When a tag in a tag expression starts with a ~, this represents boolean NOT. Example: --tags ~@dev. A tag expression can have several tags separated by a comma, which represents logical OR. Example: --tags @dev,@wip. The --tags option can be specified several times, and this represents logical AND. Example: --tags @foo,~@bar --tags @zap. This represents the boolean expression (@foo || !@bar) && @zap

因此,理论上我们可以通过以下选项使用保护文件:

Hence, in theory we can use the guardfile with these options:

guard 'cucumber', :cli => "--drb --tags @now" do
  watch(%r{^features/.+.feature$})
  ...
end

这篇关于你如何让 cucumber/guard 过滤像@wip 这样的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆