'How to run a java class only once in background, in a feature file

I have a statement in the background of a feature file as,

def token = Java.type("Calling a static method from a java class")

I have 4 scenarios in my feature file and this java class is called 4 times. How to call this java class only once?



Solution 1:[1]

Background:

  • karate.callSingle('called.feature@scenarioToBeCalledOnceInBackground');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ashrey_017