-
Notifications
You must be signed in to change notification settings - Fork 0
@JPostmanRunner
@JPostmanRunner runs multiple Postman requests from a selected folder or from the root of the collection.
Use it when you want one test method to execute many requests without writing one @JPostmanResponse method for every request.
@JPostmanRunner(
namespace = "product",
folder = "Product"
)
@Test
public void runProductFolder() {
}This runs all requests inside the Product folder.
If folder is empty, JPostman runs root-level requests from the collection.
@JPostmanRunner
@Test
public void runRootRequests() {
}Use include to run only selected requests from the folder or root.
@JPostmanRunner(
namespace = "product",
folder = "Product",
include = {
"Get all products",
"Search products"
}
)
@Test
public void runSelectedProductRequests() {
}Use exclude to skip selected requests.
@JPostmanRunner(
namespace = "product",
folder = "Product",
exclude = {
"Add a new product",
"Update a product",
"Delete a product"
}
)
@Test
public void runProductReadOnlyRequests() {
}If a request already has an explicit @JPostmanResponse method with the same namespace, folder, and request name, @JPostmanRunner skips that request.
Example explicit test:
@JPostmanResponse(
namespace = "product",
folder = "Product",
request = "Add a new product",
log = true,
verify = 201
)
@Test
public void addNewProduct() {
}Folder runner:
@JPostmanRunner(
namespace = "product",
folder = "Product"
)
@Test
public void runProductFolder() {
}The runner skips Add a new product because it already has a dedicated response test.
| Attribute | Meaning |
|---|---|
namespace |
Selects the configured JPostman context. Empty means default context. |
folder |
Optional Postman folder name. Empty means root requests. |
rule |
Optional secure rule section. |
filter |
Optional response fields to keep. |
dependsOn |
Dependency method names to run first. |
include |
Request names to include. Empty means include all. |
exclude |
Request names to exclude. |
cache |
Optional cache key for storing this method result. |
verify |
Expected HTTP status code. Default is 200. |
executor |
Named executor method. Empty means default executor. |
log |
Attach secure log details to assertion failures. |
soft |
Use soft assertion verification. |
@JPostmanRunner can use the same custom executors as @JPostmanResponse.
@JPostmanRunner(
namespace = "product",
folder = "Product",
executor = "defaultExecutor"
)
@Test
public void runProductFolder() {
}Executor with current request name:
@JPostmanExecutor
public ApiExecutor myExecutor(TestNgContext context, String methodName, String requestName) {
log.debug("=== {}::{} ==={}\n", methodName, requestName, context.log());
return RestAssuredExecutor.apply(context.request());
}For each request, requestName is the current Postman request being executed.
@JPostmanAssert applies assertion rules to each executed request.
@JPostmanRunner(
namespace = "product",
folder = "Product",
exclude = {
"Add a new product",
"Update a product",
"Delete a product"
},
log = true
)
@JPostmanAssert(sections = { "product" })
@Test
public void runProductReadOnlyRequests() {
}For each request, JPostman applies:
configured sections + current request-name section if it exists
For example, when the runner executes Get all products, it also checks for:
[Get all products]If that section exists, it is applied last and has highest priority.
Without @JPostmanAssert, the runner uses the normal verify() value.
@JPostmanRunner(
folder = "Product",
verify = 200
)
@Test
public void runProductFolder() {
}With @JPostmanAssert, the runner skips the normal verify() call and uses assertion rules instead.
@JPostmanRunner runs many Postman requests from a folder or root collection. It supports include/exclude filtering, skips explicit response tests, works with custom executors, and can apply reusable assertion rules to every executed request.