Class KarateProtocolBuilder

java.lang.Object
io.karatelabs.gatling.KarateProtocolBuilder
All Implemented Interfaces:
io.gatling.javaapi.core.ProtocolBuilder

public final class KarateProtocolBuilder extends Object implements io.gatling.javaapi.core.ProtocolBuilder
Builder for creating KarateProtocol instances. Provides a fluent API for configuring URI patterns and request naming.

Example usage:

 KarateProtocolBuilder protocol = karateProtocol(
     uri("/cats/{id}").nil(),
     uri("/cats").pauseFor(method("get", 10), method("post", 20))
 ).nameResolver((req, vars) -> req.getPath());
 
  • Field Details

    • runner

      public final io.karatelabs.core.Runner.Builder runner
      Mutable Runner.Builder for configuring underlying Karate execution. Mirrors the v1 protocol.runner field — set karateEnv, configDir, systemProperty, etc. directly on it.

      Example: protocol.runner.karateEnv("perf").configDir("src/test/resources");

      Protocol-scoped callSingle and callOnce/setupOnce caches are also pre-wired onto this builder. They live for the lifetime of the simulation (one protocol = one setUp), so an expensive karate.callSingle(...) or a feature-level callonce runs once per simulation rather than once per virtual user.

  • Constructor Details

    • KarateProtocolBuilder

      public KarateProtocolBuilder(KarateUriPattern... patterns)
      Create a new protocol builder with the given URI patterns.
  • Method Details

    • nameResolver

      public KarateProtocolBuilder nameResolver(BiFunction<io.karatelabs.http.HttpRequest,Map<String,Object>,String> resolver)
      Set a custom name resolver for HTTP requests. The resolver receives the HttpRequest and scenario variables, returning a custom name for Gatling reporting.
      Parameters:
      resolver - the name resolver function
      Returns:
      this builder for chaining
    • build

      public KarateProtocol build()
      Build the KarateProtocol.
    • protocol

      public io.gatling.core.protocol.Protocol protocol()
      Specified by:
      protocol in interface io.gatling.javaapi.core.ProtocolBuilder