# Checkpoints & Branching URL: /checkpoints Control OpenHTF test flow with checkpoints that stop on failure and branch sequences that conditionally execute phases based on diagnosis results. Stop early on failure or run phases conditionally based on diagnosis results. Not every test should run every phase. If calibration fails, there is no point running a 10-minute burn-in. OpenHTF provides two mechanisms for this: **checkpoints** that stop execution when previous phases fail, and **branch sequences** that conditionally execute phases based on diagnosis results. A checkpoint inspects the outcome of previous phases and decides whether to continue or stop. Place a checkpoint before any expensive phase you want to skip on failure. Since `calibration_phase` fails its measurement, the checkpoint triggers a `STOP` and `long_burn_in` never runs. Stop the test if any previous phase has a `FAIL` outcome. This is the most common usage. Stop only if the immediately previous phase failed. Stop if any previous phase in the entire test failed. Same as `checkpoint()`. Stop if any previous phase within the current subtest failed. Keyword accepted by all three: `PhaseResult.STOP` (default) ends the test; `PhaseResult.FAIL_SUBTEST` fails only the enclosing subtest. For simpler cases where you want the entire test to stop as soon as any measurement fails, use the `stop_on_first_failure` test option instead of checkpoints. Every checkpoint takes an `action` — `PhaseResult.STOP` by default. Inside a subtest, pass `action=htf.PhaseResult.FAIL_SUBTEST` so the checkpoint fails only that subtest and the remaining subtests still run; `PhaseFailureCheckpoint.subtest_previous(name, action=...)` limits the check to phases of the current subtest. Branch sequences execute phases conditionally based on diagnosis results. Combine them with diagnoses to build adaptive test flows. `DiagnosisCheckpoint(name, condition)` stops the test (or fails the subtest) when a diagnosis condition holds — the checkpoint counterpart of a branch: Execute branch only if ALL specified diagnosis results are present. Execute branch if ANY of the specified diagnosis results are present. Execute branch if NOT ALL of the specified results are present. Execute branch if NONE of the specified results are present.