Class KarateProtocol

java.lang.Object
io.karatelabs.gatling.KarateProtocol
All Implemented Interfaces:
io.gatling.core.protocol.Protocol

public class KarateProtocol extends Object implements io.gatling.core.protocol.Protocol
Gatling protocol for Karate feature execution. Holds configuration for URI patterns, pauses, and request naming.
  • Field Details

    • KARATE_KEY

      public static final String KARATE_KEY
      Session key for Karate variables passed between features.
      See Also:
    • GATLING_KEY

      public static final String GATLING_KEY
      Session key for Gatling variables accessible in features.
      See Also:
  • Method Details

    • getRunner

      public io.karatelabs.core.Runner.Builder getRunner()
      Get the underlying Runner.Builder template configured on the protocol builder. May be null if the protocol was constructed without one (e.g., the empty default-protocol fallback).
    • getUriPatterns

      public Map<String,KarateUriPattern> getUriPatterns()
      Get all configured URI patterns.
    • getNameResolver

      public BiFunction<io.karatelabs.http.HttpRequest,Map<String,Object>,String> getNameResolver()
      Get the custom name resolver, if configured.
    • resolveRequestName

      public String resolveRequestName(io.karatelabs.http.HttpRequest request, Map<String,Object> variables)
      Resolve the request name using the custom resolver or default pattern matching.
      Parameters:
      request - the HTTP request
      variables - the scenario variables
      Returns:
      the request name for reporting
    • resolveName

      public String resolveName(String path)
      Resolve a path to a matching URI pattern name.
      Parameters:
      path - the request path
      Returns:
      the matching pattern or null if no match
    • pathMatches

      public boolean pathMatches(String pattern, String path)
      Check if a path matches a URI pattern. Patterns can contain path parameters like "/users/{id}".
    • pauseFor

      public int pauseFor(String requestName, String method)
      Get the pause duration for a specific request and method.
      Parameters:
      requestName - the request name (usually the matched pattern)
      method - the HTTP method
      Returns:
      pause duration in milliseconds, or 0 if not configured