Skip to content

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. "Writing the API spec before implementation" — in Contract Testing, this describes which of the following?

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

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

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

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

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

  3. 3. "Machine-readable description of a REST API" — in Contract Testing, this describes which of the following?

    • A. OpenAPI specification.correct
    • B. Consumer.
    • C. Contract-first design.
    • D. Pact file.

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

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

    • A. Provider verification is performed by the consumer team manually reading logs.
    • B. Provider verification replays consumer interactions against the real provider.correct
    • C. Adding an optional new response field always breaks consumer contracts.
    • D. In consumer-driven contracts, the provider dictates what consumers must accept.

    Why: Verification proves the provider satisfies each consumer expectation.

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

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

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

  6. 6. "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.

  7. 7. Which statement correctly describes Contract Testing?

    • A. In consumer-driven contracts, the provider dictates what consumers must accept.
    • B. Provider states set up required data before verifying an interaction.correct
    • C. A Pact Broker executes load tests against providers.
    • D. Adding an optional new response field always breaks consumer contracts.

    Why: 'given user 42 exists' prepares the provider for the replayed request.

  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. Breaking changes like removing a response field are exactly what contract tests catch.correct
    • C. Adding an optional new response field always breaks consumer contracts.
    • D. Provider verification is performed by the consumer team manually reading logs.

    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. Provider.correct
    • B. Contract-first design.
    • C. Consumer.
    • D. Pact file.

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

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

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

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

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

    • 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. Provider verification replays consumer interactions against the real provider.correct
    • D. Adding an optional new response field always breaks consumer contracts.

    Why: Verification proves the provider satisfies each consumer expectation.

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

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

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

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

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

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

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

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

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

  15. 15. Which Contract Testing concept matches this description: "Machine-readable description of a REST API"?

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

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

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

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

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

  17. 17. 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.

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

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

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

  19. 19. Which Contract Testing concept matches this description: "JSON document capturing consumer-provider interactions"?

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

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

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

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

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

Related API Testing topics