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 JPostman debug output.
      String environment
      Optional Postman environment location.
      Class<?> executor
      Default API executor class for this context.
      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 and keep a successful test result. Use 1 to disable status-code verification and mark an otherwise successful completed test as skipped. Values from 2 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, 0 to pass without status verification, or 1 to mark a completed test skipped
        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
      • debug

        String[] debug
        Controls automatic JPostman debug output.
        • none - disable automatic output and keep the minimum failure stack.
        • request - include the prepared request.
        • response - include the received response.
        • info - include runtime annotation information.
        • all - include request, response, and info.
        Request, response, and info may be combined. none and all must each be used alone. Selected output is printed after each annotation execution whether that execution passes or fails.
        Returns:
        automatic debug output settings
        Default:
        {"none"}