liveBook · Manning

Behavior-driven development

As explained in Django in Action

Behavior-driven development is a software development approach that specifies and tests requirements-level behavior before or alongside implementation.

Behavior-driven development (BDD) uses tests to describe requirements-level behavior before implementation. The goal is to decide what the software should do, express that behavior in tests, and treat passing tests as evidence that the work is complete. section 8.1.1

A practical BDD workflow looks like this:

  • Define the desired behavior rather than starting with internal function details. section 8.1.1
  • Write tests before writing the implementation. section 8.1.1
  • Implement until the behavioral tests pass, then regard the function as complete. section 8.1.1
  • Run behavioral and UI tests less frequently when they are slower, while using faster unit tests more often. section 8.1.1

BDD resembles test-driven development (TDD), but shifts attention from a function’s interface to observable behavior and requirements. Detailed behavioral and UI testing may require additional tools; the boundary between unit and integration tests can also be fuzzy in Django applications. section 8.1.1

Figure 8.1 Hierarchy of testing categories
figure

Use the testing hierarchy to place behavioral tests alongside unit, integration, and UI tests, balancing coverage against execution speed. section 8.1.1

How Django in Action covers it

How deep it goes
Explains the test-first cycle and distinguishes behavioral scope, but defers detailed tools and implementation techniques.
Examples
Uses requirements-level tests and a hierarchy contrasting unit, integration, behavioral, and UI tests.
What you can do after
Apply BDD by specifying behavior in tests, implementing against those tests, and checking completion through passing results.
How it connects
Connects behavior-driven development with test-driven development, unit testing, integration testing, and UI testing.

Also explained in

Compare how 4 books explain behavior-driven development →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Django in Action. The section links point to the parts of the book it draws on.