Before All & After All

Lifecycle scripts run once per flow or load test — not once per step, not once per request. They are the place to set up test data before the run starts and to tear down, notify, or export after the run finishes. Both the Flow Runner and Load Test module expose exactly the same two hooks: Before All and After All.

When They Run

  • Before All runs exactly once, after you click Run (or Start Test), before the first step executes. In a load test, it runs before any virtual user starts.
  • After All runs exactly once, after the last step finishes. In a load test, it runs after all virtual users have stopped and the aggregated results are ready.

The Editor

Both hooks use the same full-screen editor layout, and it looks identical in the Flow Runner and the Load Test module:

  • Code editor on the left with syntax highlighting and autocomplete for the at API.
  • Snippets panel on the right, collapsible via a thin chevron strip. The snippet set differs between Before All and After All — see Snippets Panel.
  • Try button in the header — runs the script on demand, without running the whole flow or load test. Output appears in the console strip at the bottom.
  • Console strip at the bottom, showing the output of the most recent run (Try or real).

What the Script Can Use

Lifecycle scripts run on the full scripting engine — the same one that powers HTTP and flow step scripts — so every global listed in Globals is available: console, fetch, setTimeout, and top-level await.

Which parts of the at object are populated, however, is different from a step script:

  • at.environment — always works. Read and write just like in any other script.
  • at.flow — always works in Before All and After All. Variables set in Before All are visible to every step and then to After All.
  • at.request — empty. There is no single outgoing request at lifecycle scope.
  • at.response — empty. Same reason.
  • at.export — available only in After All, during a real run. In Before All and in standalone Try mode it throws.

Random Variables in the Script Body

Lifecycle scripts are special in that Atrahasis resolves {{random.*}} placeholders inside the script text itself, just before running it. A literal "{{random.string}}" in a Before All script is replaced with a fresh random string before execution — so you can paste random tokens directly into string literals without going through at.environment.

Pre-scripts and post-scripts do not get this pre-processing — there, {{random.*}}only works inside request fields (URL, headers, body), not inside script code.

Which Environment Lifecycle Scripts Use

Flow Before All / After All read from and write to the active environment of the flow group. Load Test Before All / After All read from and write to the active environment of the load test folder. Values written with at.environment.set()in Before All are immediately visible to every step and to the corresponding After All — no extra step needed.