liveBook · Manning

Longest happy path

As explained in Unit Testing Principles, Practices, and Patterns

A test scenario that exercises the complete workflow through all relevant out-of-process dependencies and produces the maximum relevant side effects.

The longest happy path is the successful scenario that exercises every relevant out-of-process dependency and produces the maximum relevant side effects. Integration testing uses it as the primary workflow, alongside edge cases that unit tests cannot exercise. section 8.3

Apply the technique by:

  • Selecting the successful workflow that crosses all out-of-process dependencies. section 8.3
  • Identifying the scenario with the greatest relevant side effects. section 8.3
  • Testing managed dependencies directly and replacing unmanaged dependencies with mocks when writing an integration test. section 8.3

Changing a corporate email

A CRM integration test changes a user from a corporate to a non-corporate email, updates both user and company records, and verifies the resulting message-bus interaction. section 8.3

Figure 8.6. The use case of changing the user’s email. The controller orchestrates the work between the database, the message bus, and the domain model.

Use the workflow diagram to trace how the controller coordinates the database, message bus, and domain model. section 8.3

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Defines scenario selection and dependency treatment, but stops short of prescribing every assertion.
Examples
Uses a CRM email change that updates user and company records and sends a message.
What it assumes
Assumes familiarity with unit tests, integration tests, and out-of-process dependencies.
What you can do after
Apply it via integration tests to prioritize the workflow with the broadest observable effect.
How it connects
Links integration testing with unit testing, edge cases, managed dependencies, unmanaged dependencies, databases, and message buses.

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.