gpt4 book ai didi

c# - cucumber : How to skip subsequent steps and exit out of the scenario without failing the step/scenario?

转载 作者:太空宇宙 更新时间:2023-11-03 12:12:11 26 4
gpt4 key购买 nike

我在 Cucumber 中有我的特征文件,我正在使用 Given, When, Then 语法 (Gherkin) 在其中编写我的场景,并在步骤定义文件中有相应的步骤。我有一个场景,我正在检查特定数据集是否存在(这是我给定步骤的一部分),然后继续我的下一步“然后”、“和”等但如果不是,那么它应该跳过其余步骤并退出步骤定义文件而不会使场景失败。有人可以建议 Cucumber 是否支持此功能吗?如果是,最好的方法是什么?

最佳答案

如果特定假设失败,您可以使用 JUnits Assume 或 TestNG 的 SkipException 将测试标记为已跳过。跳过的测试不被视为失败。

来自 https://github.com/cucumber/cucumber-jvm/tree/master/junit

Through Assume JUnit provides:

a set of methods useful for stating assumptions about the conditions in which a test is meaningful. A failed assumption does not mean the code is broken, but that the test provides no useful information. The default JUnit runner skips tests with failing assumptions. Custom runners may behave differently.

Cucumber runner 支持 Assume 并将跳过的场景标记为已跳过。

来自 https://github.com/cucumber/cucumber-jvm/tree/master/testng

Cucumber provides limited support for SkipException.

  • Throwing a SkipException results in both Cucumber and TestNG marking the test as skipped.
  • Throwing a subclass of SkipException results in Cucumber marking the test as failed and TestNG marking the test as skipped.

关于c# - cucumber : How to skip subsequent steps and exit out of the scenario without failing the step/scenario?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51615600/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com