Contract Testing interview questions — Medium

247 medium-level Contract Testing questions from our API Testing bank, each with the correct answer and an explanation of why it is correct.

What this covers

Contract Testing appears throughout API Testing interviews. At medium level, interviewers are typically checking that you have used it in practice: what you configured, what broke, and how you knew it worked. Work through these, then explain your answer out loud; the second part is what interviews actually test.

20 example questions

  1. 1. Which of the following statements about Contract Testing is TRUE?

    • A. Adding an optional new response field always breaks consumer contracts.
    • B. Contract testing requires deploying all microservices together in one environment.
    • C. Schema validation against an OpenAPI spec is a provider-driven contract approach.correct
    • D. In consumer-driven contracts, the provider dictates what consumers must accept.

    Why: Spec-based validation checks responses conform to the published schema.

  2. 2. "JSON document capturing consumer-provider interactions" — in Contract Testing, this describes which of the following?

    • A. Provider.
    • B. Can-i-deploy.
    • C. Consumer.
    • D. Pact file.correct

    Why: pact file: JSON document capturing consumer-provider interactions.

  3. 3. "Precondition the provider sets up before verification" — in Contract Testing, this describes which of the following?

    • A. Provider state.correct
    • B. Backward compatibility.
    • C. OpenAPI specification.
    • D. Provider.

    Why: provider state: Precondition the provider sets up before verification.

  4. 4. "Writing the API spec before implementation" — in Contract Testing, this describes which of the following?

    • A. Contract-first design.correct
    • B. Consumer.
    • C. Can-i-deploy.
    • D. Provider.

    Why: contract-first design: Writing the API spec before implementation.

  5. 5. "Changes that do not break existing consumers" — in Contract Testing, this describes which of the following?

    • A. OpenAPI specification.
    • B. Backward compatibility.correct
    • C. Can-i-deploy.
    • D. Provider.

    Why: backward compatibility: Changes that do not break existing consumers.

  6. 6. Which statement correctly describes Contract Testing?

    • A. A Pact Broker executes load tests against providers.
    • B. Adding an optional new response field always breaks consumer contracts.
    • C. Schema validation against an OpenAPI spec is a provider-driven contract approach.correct
    • D. Provider verification is performed by the consumer team manually reading logs.

    Why: Spec-based validation checks responses conform to the published schema.

  7. 7. "Service or app that calls the API" — in Contract Testing, this describes which of the following?

    • A. Backward compatibility.
    • B. Pact file.
    • C. Provider state.
    • D. Consumer.correct

    Why: consumer: Service or app that calls the API.

  8. 8. Identify the accurate statement about Contract Testing:

    • A. Contract tests are slower and flakier than full end-to-end tests by nature.
    • B. Provider verification is performed by the consumer team manually reading logs.
    • C. Breaking changes like removing a response field are exactly what contract tests catch.correct
    • D. In consumer-driven contracts, the provider dictates what consumers must accept.

    Why: Removed or renamed fields fail consumer expectations immediately.

  9. 9. "Service that implements and serves the API" — in Contract Testing, this describes which of the following?

    • A. Pact file.
    • B. Provider.correct
    • C. Provider state.
    • D. OpenAPI specification.

    Why: provider: Service that implements and serves the API.

  10. 10. Which Contract Testing concept matches this description: "Changes that do not break existing consumers"?

    • A. Consumer.
    • B. Provider.
    • C. Backward compatibility.correct
    • D. OpenAPI specification.

    Why: backward compatibility: Changes that do not break existing consumers.

  11. 11. In the context of Contract Testing, which of the following is a correct statement?

    • A. A Pact Broker executes load tests against providers.
    • B. In consumer-driven contracts, the provider dictates what consumers must accept.
    • C. Adding an optional new response field always breaks consumer contracts.
    • D. Contract testing verifies that a consumer and provider agree on the API's request/response structure.correct

    Why: Contracts catch integration breaks without full end-to-end environments.

  12. 12. In Contract Testing, which of the following is described as: "Writing the API spec before implementation"?

    • A. Provider.
    • B. Backward compatibility.
    • C. Contract-first design.correct
    • D. OpenAPI specification.

    Why: contract-first design: Writing the API spec before implementation.

  13. 13. Which Contract Testing concept matches this description: "Writing the API spec before implementation"?

    • A. Contract-first design.correct
    • B. Pact file.
    • C. Provider state.
    • D. Provider.

    Why: contract-first design: Writing the API spec before implementation.

  14. 14. In Contract Testing, which of the following is described as: "Changes that do not break existing consumers"?

    • A. Provider.
    • B. Consumer.
    • C. OpenAPI specification.
    • D. Backward compatibility.correct

    Why: backward compatibility: Changes that do not break existing consumers.

  15. 15. In Contract Testing, which of the following is described as: "JSON document capturing consumer-provider interactions"?

    • A. OpenAPI specification.
    • B. Backward compatibility.
    • C. Can-i-deploy.
    • D. Pact file.correct

    Why: pact file: JSON document capturing consumer-provider interactions.

  16. 16. In Contract Testing, which of the following is described as: "Machine-readable description of a REST API"?

    • A. OpenAPI specification.correct
    • B. Backward compatibility.
    • C. Consumer.
    • D. Contract-first design.

    Why: OpenAPI specification: Machine-readable description of a REST API.

  17. 17. In Contract Testing, which of the following is described as: "Precondition the provider sets up before verification"?

    • A. Provider state.correct
    • B. OpenAPI specification.
    • C. Contract-first design.
    • D. Consumer.

    Why: provider state: Precondition the provider sets up before verification.

  18. 18. Which Contract Testing concept matches this description: "Precondition the provider sets up before verification"?

    • A. OpenAPI specification.
    • B. Provider state.correct
    • C. Contract-first design.
    • D. Can-i-deploy.

    Why: provider state: Precondition the provider sets up before verification.

  19. 19. Which Contract Testing concept matches this description: "Broker check confirming compatible versions before release"?

    • A. Backward compatibility.
    • B. Contract-first design.
    • C. Can-i-deploy.correct
    • D. Consumer.

    Why: can-i-deploy: Broker check confirming compatible versions before release.

  20. 20. In Contract Testing, which of the following is described as: "Broker check confirming compatible versions before release"?

    • A. Can-i-deploy.correct
    • B. Provider.
    • C. Backward compatibility.
    • D. Provider state.

    Why: can-i-deploy: Broker check confirming compatible versions before release.

Related API Testing topics