gpt4 book ai didi

cucumber - 如何让 Cucumber/guard 过滤 @wip 等标签?

转载 作者:行者123 更新时间:2023-12-03 06:30:38 26 4
gpt4 key购买 nike

我正在运行 Spork 和 Guard,我的 RSpec 测试一切进展顺利,所有测试都运行正确。为了加快测试速度,我可以使用放置在 .rspec 文件中的标签成功过滤 RSpec 测试。

.rspec

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

不幸的是,我无法过滤我的 cucumber 标签。每次 Cucumber 运行时,它都会运行所有内容或仅运行更改的文件。

如何让 cucumber/spork/guard 尊重 @wip、@now 等标签并仅运行这些测试?是否有与 cucumber 标签的 .rspec 文件等效的文件?

最佳答案

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

wip: --tags @wip

更多信息:

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

您还可以从命令行运行 cucumber 并向其传递 -t 参数:

cucumber -t @wip,@now

来自帮助(cucumber -h):

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

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

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

关于cucumber - 如何让 Cucumber/guard 过滤 @wip 等标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9193120/

26 4 0