liveBook · Manning

System under test

As explained in Unit Testing Principles, Practices, and Patterns

The system under test is the class, component, or larger unit whose behavior a test exercises and verifies.

The system under test (SUT) is the class, component, or larger unit whose behavior a test exercises and verifies. In unit-testing discussions, its boundary depends on the testing school: the London school centers on one class, while the classical school centers on one meaningful unit of behavior. section 2.1 section 2.5

Treat the SUT as a testing boundary, not automatically as the smallest code artifact:

  • Isolate the SUT from collaborators with test doubles when following the London style; this separates the class's behavior from external influence. section 2.1
  • Keep relevant collaborators intact under the classical style, replacing shared dependencies only when they could make tests affect one another. section 2.5
  • Prefer a unit of behavior that expresses a meaningful domain outcome over a test aimed narrowly at one class or implementation detail. section 2.3 section 2.5

Testing a purchase

A classical test constructs a customer and store, performs a shampoo purchase, and verifies success plus remaining inventory. A London-style test replaces the store with a mock, configures inventory availability, and verifies that removal occurs once. Both exercise purchasing behavior, but the second couples the test more closely to the SUT's collaborator interactions.

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Contrasts class-centered and behavior-centered boundaries, then demonstrates each with collaborator-isolation examples.
Examples
Uses customer purchases, store inventory, mocks, and interaction verification to contrast classical and London-style tests.
What it assumes
Assumes object-oriented classes and dependencies, while defining test doubles and the competing isolation approaches.
What you can do after
Evaluate whether a test verifies meaningful behavior or over-specifies the SUT's implementation and collaborator interactions.
How it connects
Connects the SUT to unit testing, test doubles, dependencies, isolation, integration testing, and implementation details.

Also explained in

Compare how 4 books explain system under test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.