Mutable Environment
The Environment is the cross-step context store of the orchestration — the only mutable, shared state across step executions. It passes data between the consumer and the library, and across steps during execution.
-
Use-cases to mutate are usually in Pre-req and Post-res scripts (using
pm.environment.set()) and Pre-Step/Post-Step Hooks (using the referencerundown.mutableEnv) during execution. -
Mutable Environment is
Map<String, Object>(in Java) orMap<String, Any?>(in Kotlin), so you can store any type of value, not justString.
|
|
If a mutableEnv entry holds a POJO value, the value gets mutated to a serialized JSON String inside the mutableEnv before being used for variable replacement. This also recursively replaces any variable placeholders inside POJO attribute values. Although we can, the value is not deserialized back to POJO for perf reasons. You can always read a specific value back as POJO, as needed.
|
Read Mutable Environment as Postman Environment JSON format
You may want to troubleshoot manually with Postman using the Mutable environment built during the ReṼoman execution. rundown.mutableEnv.postmanEnvJSONFormat() converts the mutable environment into a Postman JSON format, so you can copy and import that environment conveniently into Postman.
| You do NOT need to save the copied Postman environment JSON from the debugger into a file. You can paste (Ctrl+v) directly in the Postman environment window. |
Read Environment value into Strong type
You can read any value from mutableEnv as a Strong type using rundown.mutableEnv.<TypeT>getTypedObj(). See it in action: the getTypedObj() test in PostmanEnvironmentTest.
While serializing/deserializing, the custom adapters configured via Kick config are used. You may supply more adapters if needed via Kick config.
|