是否有黄瓜钩在每个功能之前和之后运行 [英] Is there a cucumber hook to run before and after each feature

查看:146
本文介绍了是否有黄瓜钩在每个功能之前和之后运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法运行特定代码块之前和之后每个黄瓜功能与某些标签?

Is there a way to run specific code block before and after each cucumber feature with certain tag?

由于安装过程非常昂贵,我不想在每个场景之前运行它。

Since setup process is very expensive I don't want to run it before each scenario.

推荐答案

几天前,我和Matt Wynne(黄瓜宝石的核心团队成员之一)谈过,他告诉我黄瓜没有这样的功能(在写这篇文章的时候)。

Few days ago I've spoke with Matt Wynne (one of the core team member of cucumber gem) and he told me that there is no such feature in cucumber (at the time of writing this).

作为解决方法,他建议在每个钩子之前标记整个功能和使用,如下所示:

As a workaround he suggested to tag whole feature and use before each hook with a flag like so:

Before('@feature_with_expensive_setup') do
  unless @setup_is_done
    # perform expensive setup code here ..
    @setup_is_done = true
  end
end

这篇关于是否有黄瓜钩在每个功能之前和之后运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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