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 reference rundown.mutableEnv) during execution.

  • Mutable Environment is Map<String, Object> (in Java) or Map<String, Any?> (in Kotlin), so you can store any type of value, not just String.

rundown.mutableEnv is the pm.environment scope specifically — the workhorse store that holds typed POJOs, feeds the warm-run ledger, and is written directly by hooks. It is one of three persistent Postman scopes ReṼoman models; the siblings pm.collectionVariables and pm.globals are exposed alongside it as rundown.collectionVariables and rundown.globals. All three are read by {{key}} substitution and pm.variables.get(…​) per the precedence chain, but only mutableEnv (the environment scope) participates in the ledger and accepts non-script (POJO) values.

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.

pmEnvSnapshot in each StepReport

Each StepReport also has a pmEnvSnapshot to assert if a step has executed as expected and to compare snapshots from different steps to examine execution progress.