Learn / macOS

Practice reasoning about service contracts

Use Contract Testing lessons to understand how independent consumers and providers can evolve safely.

Contract Testing with the ordered curriculum and a boundary-contract lesson.
Contract Testing with the ordered curriculum and a boundary-contract lesson. Select the image to enlarge.
  1. Identify the boundary

    Read the scenario and list what the consumer actually uses from a request, response, or event.

    Example

    An order summary uses id, total, and currency. A new internal database field should not require changing that consumer.

  2. Predict the breaking change

    Complete a drill by comparing the old and new contracts. Explain which consumer assumption fails.

    Example

    Renaming total to amount breaks a consumer that reads total. Adding an optional field may preserve the existing consumer’s behavior.

  3. Rehearse verification

    Use the lesson’s provider-verification example to explain the check you would run before release. Describe compatibility and a staged change.

    Example

    Introduce amount while retaining total, migrate the consumer, then remove total after verifying that no supported consumer depends on it.

Check your work

You can distinguish an implementation change from a consumer-visible contract change and propose a verification step.

Try it yourself

A consumer reads order status from a service response. Add a new possible status and decide how a consumer with an exhaustive status switch would handle it.

What to look for
The shape can remain valid while the behavior breaks. Identify the affected consumer and what compatibility behavior its contract needs to verify.