liveBook · Manning

Backward compatibility

As explained in Unit Testing Principles, Practices, and Patterns

The ability of a system or communication contract to remain usable by existing external clients after internal changes.

Backward compatibility keeps existing external clients usable after internal changes by preserving the communication contract between applications. Messages, service calls, and parameter structures must remain understandable to systems that evolve on different deployment cycles. section 5.3 section 5.4

Apply the requirement according to where communication crosses the system boundary:

  • Verify inter-system communication with mocks or spies because emitted messages and external calls form observable behavior. section 5.3
  • Mock the last stage before an unmanaged dependency leaves the application; this preserves the external format while resisting internal refactoring. section 9.1
  • Treat communication with an application-only database as an implementation detail; change its schema or storage mechanism without preserving its internal protocol. section 5.4
  • Avoid mocking collaborations between internal classes, because preserving those calls couples tests to implementation details rather than client-visible behavior. section 5.3

Testing a message contract at the system edge

A controller sends an email-change event through IMessageBus, which formats it for IBus. Testing IMessageBus verifies an intermediate collaboration; injecting a mock IBus instead verifies the final message—"Type: USER EMAIL CHANGED; Id: ...; NewEmail: ..."—and therefore protects the external contract. A handwritten BusSpy can record messages and expose readable assertions for message count and structure.

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Distinguishes inter-system from intra-system communication and specifies where mocks, spies, or no interaction verification belong.
Examples
Uses message-bus payloads, SMTP calls, application databases, email gateways, and a BusSpy to demonstrate stable and unstable boundaries.
What it assumes
Distinguishes external applications from internal classes and recognizes observable behavior as a system-level contract.
What you can do after
Apply mocks or spies at system edges to verify externally visible message structures and calls without freezing internal collaborations.
How it connects
Connects observable behavior, inter-system communication, mocks, spies, test doubles, integration tests, and implementation details.

Also explained in

Compare how 18 books explain backward compatibility →

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.