Annotation Type JPostmanContext
-
@Target(FIELD) @Retention(RUNTIME) public @interface JPostmanContext
Injects the loaded JPostman context.A field may use the core
JPostman.Contexttype when it only needs direct access to the loaded Postman collection/environment. A field may also useJPostmanRuntimeor the compactJPostman.Contextalias when it needs annotation-runtime access such as the active framework context, namespace-specific contexts, or the currentJPostmanInfo.@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[]assertionsOptional assertion rule files to load for annotation assertions.StringcollectionOptional Postman collection location.StringconfigProperties file to load context locations from.String[]dataloadOptional data files to load for annotation data resolvers.String[]debugControls automatic annotation output.StringenvironmentOptional Postman environment location.Class<?>executorDefault API executor class for this context.String[]logsControls automatic JPostman failure output.StringrulesOptional secure rules location.booleansessionEnables session executor mode for the context default executor.booleanskipAllSkips all JPostman response and runner test executions by default.intverifyStatusCodeDefault HTTP status code used when a response or runner does not specifyverify.
-
-
-
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.inior 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.inior 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 specifyverify.The default value is
200. This means executedJPostmanResponseandJPostmanRunnerrequests are verified as HTTP 200 unless they define their ownverifyvalue.Use
0to disable default status-code verification. Values from1to99are invalid because the lowest standard HTTP status code is100; values greater than599are also invalid.- Returns:
- default expected HTTP status code, or
0to 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
JPostmanExecutormethod. For non-session execution, the executor class must provide a staticapply(request)method returningApiExecutor. For session execution, it must provide a staticcreate()method returningApiExecutor.- Returns:
- executor class, or
Voidwhen 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 withexecutor.apply(ctx.request()). Whentrue, JPostman creates and reuses the default executor withexecutor.create().- Returns:
trueto use session mode;falseto create an executor per request
- 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.
logs = "request",logs = { "request", "response" }, orlogs = { "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, andinfomay be combined.noneandallmust be used alone.- Returns:
- debug output mode values
- Default:
- {"none"}
-
-