Setup / Teardown

Last updated on October 28, 2026

You can organize phases into setup, main, and teardown stages. Setup runs first and must complete successfully. Main runs after setup passes. Teardown always runs at the end, even if earlier phases fail.

Setup

You can add a setup section and register phases like in main.

setup: 
  - name: Setup Phase 1
  - name: Setup Phase 2

main:
  - name: Main Phase

TofuPilot runs main only if all setup phases pass, otherwise stops the test.

Teardown

You can add a teardown section and register phases like in main.

main:
  - name: Main Phase

teardown: 
  - name: Teardown Phase 1
  - name: Teardown Phase 2

TofuPilot always runs teardown phases, even if setup or main phases fail. On a multi-slot run, a slot's teardown runs once the slot was touched: one of its phases ran, its plugs opened, or a shared (scope: execution) setup phase failed. Only a slot nothing reached skips it: a slot still waiting its turn under strategy: slot_first (a failed shared setup included), or a stop before any plug opened. A teardown phase that takes a plug the slot never opened reads SKIP. A teardown phase reports its own outcome: PASS when it ran, ERROR with the traceback when it raised, even when the run is already stopping.

Full Example

You can use setup, main, and teardown phases in the same procedure:

name: Full Procedure

setup:
  - name: Setup Phase 1
  - name: Setup Phase 2

main:
  - name: Main Phase

teardown:
  - name: Teardown Phase 1
  - name: Teardown Phase 2

How is this guide?

On this page