Karate - Disable hook for called feature using execution Hook

Viewed 78

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);
1 Answers

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()

Related