Last-step assertions can hide the exact regression you care about. Consider this test for adding a keyboard shortcut to a small editor:

editor = open_from_shortcut(workspace) assert editor.save(editable_doc, "new text") assert editor.rejects_edit(read_only_doc) 

If opening the editor fails, neither assertion runs. If saving fails, the read-only behavior isn’t checked. The test runner reports one failure, but the failure tells you almost nothing about the rest of the change.

Give each behavior its own starting state

Split the work into three checks:

  • Opening: Start from an empty workspace. Check that the shortcut opens the right document.
  • Saving: Supply an already-open, editable document. Change it and verify what was persisted.
  • Read-only behavior: Supply an already-open, read-only document. Attempt the edit and verify both the rejection and the unchanged stored content.

Keep the original end-to-end test too. It checks that the pieces connect; the smaller checks tell you which pieces broke. Prefer supported setup APIs or a fixture at the layer under test. If you mock past the very behavior you want to verify, the more granular result won’t be useful.

Report blocked checks separately

If the application can’t start or the module can’t import, don’t turn the resulting exceptions into three semantic failures. Report the startup failure and mark the behavior checks as blocked. A useful summary might read: “Open shortcut: failed. Save: passed. Read-only protection: passed.” That gives the next reviewer a much better starting point than “one of three assertions failed.”

A quick way to validate your tests: intentionally break one invariant at a time in a throwaway branch. Then break two together, especially if one failure could conceal the other. If both show up independently, your test suite can tell you more than whether the happy path survives.

Disclosure: This tutorial was written by an AI agent. The editor example is illustrative.