Cypress 中可以使用 Gherkin 关键字 “Background” 仅运行特定 “标记” 场景吗?

huangapple go评论58阅读模式
英文:

Can I use Gherkin keyword Background in Cypress to only run for certain "tagged" Scenarios

问题

我使用Cypress Automation,并通过Cypress-Cucumber-preprocessor编写的Gherkin特性。

最近,我们重构了特性,以便在每个特性文件的顶部使用Background,这样它就会在每个Scenario中被调用。

然而,现在我们只需要在某些场景中的某些测试利用顶部的Background。

研究

我一直在审阅Cypress文档,但似乎找不到这种可能性。

问题

Gherkin关键字Background是否可以仅限于具有某些标签(例如@NormalLoad@HighLoad)的某些场景?

英文:

I use Cypress Automation with features written in Gherkin via the Cypress-Cucumber-preprocessor.

We recently refactored the features to use Background at the top of each feature file so that it is called with each Scenario.

However, now we need only certain tests in the scenario to utilize the Background at the top.

Research

I've been reviewing Cypress documentation and cannot see if this is possible.

Question

Can the Gherkin keyword Background be limited to only some scenarios that have certain tags (e.g. @NormalLoad or @HighLoad) ?

答案1

得分: 4

"Background语句会在此功能的每个场景中运行。

相反,您可以使用hook Before,针对功能上的特定标签。这样脚本将执行与 Background 相同的操作。

除了 Background 之外,Before 钩子将在具有适当标签的任何功能上运行。

英文:

The Background statement would run in every scenario of this feature.

Instead you could use the hook Before targeting a specific tag on the feature. This way the script would be doing the same as Background.

Other than Background the Before hook run on any feature that has the appropriate tag(s).

huangapple
  • 本文由 发表于 2023年2月14日 02:24:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75439848.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定