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 JPostman debug output.StringenvironmentOptional Postman environment location.Class<?>executorDefault API executor class for this context.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 and keep a successful test result. Use1to disable status-code verification and mark an otherwise successful completed test as skipped. Values from2to99are invalid because the lowest standard HTTP status code is100; values greater than599are also invalid.- Returns:
- default expected HTTP status code,
0to pass without status verification, or1to 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
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
-
-
-
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.
noneandallmust 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"}
-
-