Skip to main content
InterviewHubPRO
Section Overview
Q25

Question 25 of 50

Part 3: Advanced Internals, Scale & Production Quality (Senior / Lead)

50%
Software Testing & QA (50 Qs)•Part 3: Advanced Internals, Scale & Production Quality (Senior / Lead)

Consumer-Driven Contract Testing with Pact for Microservices.

senior LevelTestingMicroservices

In Simple Words: In a microservices architecture with 50 services, running full E2E environments for every PR is slow, expensive, and fragile. Consumer-Driven Contract Testing (Pact):

  1. Consumer Defines Contract: The frontend or downstream service writes unit tests defining the exact request it sends and the minimum response payload it needs. Pact outputs a pact.json contract file.
  2. Provider Verifies Contract: The upstream backend API imports pact.json and runs an automated test against its real controller endpoints.
  3. If the backend changes a field type or deletes an endpoint, the contract test fails immediately in CI before deployment, guaranteeing cross-service compatibility without spinning up full E2E environments!