空手道 - 使用执行挂钩禁用挂钩用于称为功能的挂钩

发布于 2025-01-23 21:22:40 字数 416 浏览 1 评论 0 原文

我正在空手道中使用执行挂钩接口进行自定义报告,在这里,我在情况下使用称为功能。 由于我的场景包含称为功能,因此在运行它时将第二次beforescenario零件,因此是否有任何方法可以禁用挂钩以获取所谓的功能。

因为称为功能是我的场景中的一步,所以我们如何作为单独的场景条件制作。

公共类CustomHook实现executionhook {

@Override
public boolean beforeScenario(Scenario scenario, ScenarioContext context) {
    boolean skip =false;
    String currentTestcase=scenario.getName();
    System.out.println(currentTestcase);

I am using Execution hook interface in karate for customised report, here i am using called feature in my scenario.
Since my scenario contain called feature, while running it is coming to BeforeScenario Part for second time , is there any way to disable hooks for called feature.

Because called feature is one step in my scenario , how can we make as separate scenario condition.

public class CustomHook implements ExecutionHook {

@Override
public boolean beforeScenario(Scenario scenario, ScenarioContext context) {
    boolean skip =false;
    String currentTestcase=scenario.getName();
    System.out.println(currentTestcase);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪装你 2025-01-30 21:22:40

这是空手道的旧版本,不再受支持。许多团队都遵循了迁移指南,并处于领先地位:

您可以通过调用 sceparioruntime.caller.caller.caller.depth or 或<代码> specarioruntime.caller.isnone()

This is an old version of Karate which is no longer supported. Many teams have followed the migration guide and are far ahead: https://github.com/karatelabs/karate/wiki/1.0-upgrade-guide#hooks

And you can easily check if this is the root scenario or not by calling ScenarioRuntime.caller.depth or ScenarioRuntime.caller.isNone()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文