liveBook · Manning

Interaction testing

Interaction testing is a testing technique that verifies how a unit under test interacts with its collaborators, such as which calls it makes and with what parameters.

How 2 Manning books explain it

Test Driven: Practical TDD and Acceptance TDD for Java Developers

Interaction-based testing verifies behavior by checking interactions between the system under test and its collaborators.

How it is used
Uses interaction testing to verify collaboration with difficult dependencies without relying on their real implementations.
How deep it goes
Contrasts state and interaction testing, then walks through recording expectations and replaying a mock.
Examples
Uses an OrderProcessor with a mock PricingService and contrasts it with checking a list’s state after adding an item.
What you can do after
Apply it via EasyMock by recording expected calls and responses, switching to replay mode, and exercising the object under test.

Read how Test Driven: Practical TDD and Acceptance TDD for Java Developers explains interaction testing →

The Art of Unit Testing 3e

A testing technique that verifies how a unit of work interacts with its outgoing dependencies, including the calls made and their parameters.

How it is used
Checks calls from isolated units to dependencies they do not control.
How deep it goes
Defines mocks, stubs, exit points, injection approaches, and overspecification trade-offs without detailing framework internals.
Examples
Uses a logger call, mock assertions, dependency injection variants, and expectations that become fragile through overspecification.
What you can do after
Diagnose dependency-boundary behavior by injecting mocks and verifying important calls with their parameters.

Read how The Art of Unit Testing 3e explains interaction testing →

What to know first

Related concepts

Questions about interaction testing

What is interaction testing?

Interaction testing is a testing technique that verifies how a unit under test interacts with its collaborators, such as which calls it makes and with what parameters.

Which Manning books explain interaction testing?

Test Driven: Practical TDD and Acceptance TDD for Java Developers and The Art of Unit Testing 3e.

What should I know before learning interaction testing?

Manning books that teach interaction testing usually introduce stub and test double first.

What is the difference between interaction testing and state-based testing?

Interaction testing is a testing technique that verifies how a unit under test interacts with its collaborators, such as which calls it makes and with what parameters. State-based testing is a testing style that verifies behavior by examining the observable state of the system or its collaborators after an operation.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.