liveBook · Manning

Sanity check

As explained in Effective Behavior-Driven Development

A pattern that verifies setup preconditions immediately, before later steps depend on them.

A sanity check verifies that a setup step actually established the context later steps need. It catches problems at their source instead of letting them surface as confusing failures downstream. section 19.6 section 19.0

Add an explicit check when a setup call can fail without throwing an exception or confirming completion. If the call already verifies success, an extra check may not be needed. Prefer a generic check where possible; use a custom one when a generic check will not work. section 19.6 section 19.7

Common reasons to check setup immediately include:

  • Navigating to a login page does not confirm that it loaded correctly. section 19.6
  • A REST API call may return an unsuccessful status without raising an exception. section 19.6
  • An asynchronous action may still be running when its call returns. section 19.6
  • An API function may return an error code instead of throwing an exception. section 19.6

Check before moving on

A REST API context can check the response status; a CSV-loading step can check that the file contains at least one record. Both checks reveal a setup problem before later steps rely on that context. section 19.6

How Effective Behavior-Driven Development covers it

How deep it goes
Explains when checks are needed, gives failure cases, and favors generic checks, with custom checks when necessary.
Examples
Uses login-page loading, REST API status codes, asynchronous completion, API error codes, and CSV records as examples.
What you can do after
Apply explicit checks to setup steps whose success or completion is not otherwise confirmed.
How it connects
Connects context setup with REST APIs, asynchronous actions, exceptions, and automated BDD scenarios.

Also explained in

Compare how 2 books explain sanity check →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Behavior-Driven Development. The section links point to the parts of the book it draws on.