在黄瓜中使用背景标题作为背景 [英] Using Background title as Background in cucumber
问题描述
假设我使用后台功能,该功能具有以下步骤:
Let's say I use Background feature which has the below steps:
Background: My pre-requisites
Given Step one
When Step Two
Then Step Three
....
Then Step Fifteen
因此,基本上,我的背景"有15个常见步骤才能运行一组方案.
So basically my Background has 15 common steps that is required for a set of scenario to run.
我的问题是:是否可以在其他功能文件中使用背景标题My pre-requisites
,而不是将所有15个步骤记为背景?还是有其他方法可以更优雅地处理此问题.
My question is : Is it possible to use the Background title My pre-requisites
in other feature files, instead of writing down all the 15 steps as Background? Or is there any other way to handle this more gracefully.
推荐答案
您可以创建一个before钩子,对背景逻辑进行编码,并在所有功能文件中重复使用它.甚至标记该钩子,以便您可以过滤掉您不希望运行前钩子的情况.
You can create a before hook to code the background logic and reuse it across any feature file. Even tag the hook so u can filter out scenarios where u do not want the before hook to run.
这篇关于在黄瓜中使用背景标题作为背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!