Annotation Type JPostmanContext


  • @Target(FIELD)
    @Retention(RUNTIME)
    public @interface JPostmanContext
    Injects the loaded JPostman context.

    A field may use the core JPostman.Context type when it only needs direct access to the loaded Postman collection/environment. A field may also use JPostmanRuntime or the compact JPostman.Context alias when it needs annotation-runtime access such as the active framework context, namespace-specific contexts, or the current JPostmanInfo.

     @JPostmanContext(collection = "classpath:collection.json")
     private JPostmanRuntime<TestNgContext> jctx;
    
     // Or with the compact facade import:
     private io.jpostman.annotations.JPostman.Runtime<TestNgContext> jctx;
    
     jctx.ctx(); // latest active framework context
     jctx.ctx(""); // default framework context
     jctx.ctx("product"); // namespace-specific framework context
     jctx.info(); // current JPostmanInfo
     
     
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String[] assertions
      Optional assertion rule files to load for annotation assertions.
      String collection
      Optional Postman collection location.
      String config
      Properties file to load context locations from.
      String[] dataload
      Optional data files to load for annotation data resolvers.
      String[] debug
      Controls automatic annotation output.
      String environment
      Optional Postman environment location.
      Class<?> executor
      Default API executor class for this context.
      String[] logs
      Controls automatic JPostman failure output.
      String rules
      Optional secure rules location.
      boolean session
      Enables session executor mode for the context default executor.
      boolean skipAll
      Skips all JPostman response and runner test executions by default.
      int verifyStatusCode
      Default HTTP status code used when a response or runner does not specify verify.
    • Element Detail

      • config

        String config
        Properties file to load context locations from.
        Returns:
        context configuration location
        Default:
        "classpath:jpostman.properties"
      • collection

        String collection
        Optional Postman collection location.
        Returns:
        Postman collection location
        Default:
        ""
      • environment

        String environment
        Optional Postman environment location.
        Returns:
        Postman environment location
        Default:
        ""
      • rules

        String rules
        Optional secure rules location.
        Returns:
        secure rules location
        Default:
        ""
      • dataload

        String[] dataload
        Optional data files to load for annotation data resolvers.

        Locations may use the same format as other JPostman resources, for example classpath:product-data.ini or a file-system path. Multiple files are loaded in declaration order. Section names must be unique across all loaded data files; duplicate section names fail fast instead of being overridden.

        Returns:
        data file locations
        Default:
        {}
      • assertions

        String[] assertions
        Optional assertion rule files to load for annotation assertions.

        Locations may use the same format as other JPostman resources, for example classpath:annotation-test-assertions.ini or a file-system path. Multiple files are loaded in declaration order. Section names must be unique across all loaded assertion files; duplicate section names fail fast instead of being overridden.

        Returns:
        assertion rule file locations
        Default:
        {}
      • verifyStatusCode

        int verifyStatusCode
        Default HTTP status code used when a response or runner does not specify verify.

        The default value is 200. This means executed JPostmanResponse and JPostmanRunner requests are verified as HTTP 200 unless they define their own verify value.

        Use 0 to disable default status-code verification. Values from 1 to 99 are invalid because the lowest standard HTTP status code is 100; values greater than 599 are also invalid.

        Returns:
        default expected HTTP status code, or 0 to skip status code verification by default
        Default:
        200
      • executor

        Class<?> executor
        Default API executor class for this context.

        When configured, JPostman can execute requests without a code-defined default JPostmanExecutor method. For non-session execution, the executor class must provide a static apply(request) method returning ApiExecutor. For session execution, it must provide a static create() method returning ApiExecutor.

        Returns:
        executor class, or Void when no context executor is configured
        Default:
        java.lang.Void.class
      • session

        boolean session
        Enables session executor mode for the context default executor.

        When false, JPostman creates the default executor with executor.apply(ctx.request()). When true, JPostman creates and reuses the default executor with executor.create().

        Returns:
        true to use session mode; false to create an executor per request
        Default:
        false
      • skipAll

        boolean skipAll
        Skips all JPostman response and runner test executions by default.

        Individual response or runner annotations can opt back in with enabled = true.

        Returns:
        true to skip all JPostman test executions by default
        Default:
        false
      • logs

        String[] logs
        Controls automatic JPostman failure output. Values may combine one stack mode with optional failure diagnostics.
        • none - print only the minimum failure message and the first useful user-code stack frame. This is the default.
        • error - print the failure message and include the trace.
        • request - include the prepared request when a failure occurs.
        • response - include the received response when a failure occurs.
        • info - include runtime annotation info when a failure occurs.
        • all - include request, response, and info when a failure occurs.
        Examples: logs = "request", logs = { "request", "response" }, or logs = { "error", "response" }.
        Returns:
        automatic failure output mode and diagnostics
        Default:
        {"none"}
      • debug

        String[] debug
        Controls automatic annotation output.
        • none - do not print automatic annotation output.
        • request - print the prepared request.
        • response - print the received response.
        • info - print runtime annotation information.
        • all - print request, response, and info output.
        request, response, and info may be combined. none and all must be used alone.
        Returns:
        debug output mode values
        Default:
        {"none"}