Skip to main content
Back to case studies

Building Contract Testing Infrastructure from Scratch

How I implemented a comprehensive contract testing solution at EPAM Systems, reducing integration test time by 40% and preventing breaking changes in a microservices architecture.

EPAM Systems
6 months
40% faster integration testing
15 microservices

The Challenge

The e-commerce platform consisted of 15 microservices (Product Catalog, Cart, Orders, Payment, Inventory, etc.) communicating via REST APIs.

Problems we faced:

  • Breaking changes went unnoticed until production deployments
  • E2E tests were slow (35 minutes) and brittle
  • Integration tests were flaky due to inter-service dependencies
  • No API versioning strategy - teams deployed independently
  • 12 false positives per month wasted developer time

The Solution

Implemented consumer-driven contract testing using Pact and Pactum to verify API contracts between microservices.

Key components:

Contract Testing Flow

┌─────────────────┐                  ┌─────────────────┐
│   Consumer      │                  │    Provider     │
│  (Frontend/     │                  │  (Product API)  │
│   Cart Service) │                  │                 │
└────────┬────────┘                  └────────┬────────┘
         │                                    │
         │ 1. Generate Contract               │
         │    (Pact file)                     │
         ├────────────────┐                   │
         │                │                   │
         │                v                   │
         │         ┌──────────────┐           │
         │         │ Pact Broker  │           │
         │         │  (Contract   │           │
         │         │   Storage)   │           │
         │         └──────┬───────┘           │
         │                │                   │
         │                │ 2. Publish        │
         │                │    Contract       │
         │                │                   │
         │                │ 3. Verify         │
         │                │    Against        │
         │                │    Contract       │
         │                └───────────────────┤
         │                                    │
         │ 4. ✅ Contract Valid or            │
         │    ❌ Breaking Change Detected     │
         └────────────────────────────────────┘

Consumer Contract Example

Provider Verification Example

Implementation Timeline

Week 1-2

Research & Proof of Concept

Evaluated contract testing tools (Pact, Spring Cloud Contract), analyzed existing microservices architecture, and built POC with Pact.

Week 3-4

Pact Implementation

Set up PactBroker, created consumer-driven contracts for critical services, integrated with CI/CD pipeline.

Week 5-8

Provider Verification

Implemented provider verification tests, configured webhooks for contract changes, added contract testing to all microservices.

Week 9-12

Team Training & Documentation

Conducted workshops for developers, created documentation and best practices guide, set up monitoring and alerts.

Week 13-16

Rollout & Optimization

Rolled out to all teams, optimized contract generation, integrated with API versioning strategy.

Week 17-24

Monitoring & Iteration

Monitored contract violations, gathered feedback, refined process based on real-world usage.

Results & Impact

Performance Improvement

Key Achievements

40%

Faster integration testing (35min → 21min)

87%

Reduction in breaking changes reaching production

75%

Fewer false positives (12 → 3 per month)

100%

Test coverage for critical API contracts

Technologies Used

PactPactumPactBrokerTypeScriptJestGitLab CIDockerNode.jsREST APIMicroservices

Lessons Learned

1. Start with Critical Services

Begin with the most critical consumer-provider pairs (e.g., Frontend → Product API) to demonstrate value quickly.

2. Team Buy-In is Essential

Conduct hands-on workshops and show real examples of breaking changes being caught to get team support.

3. Automate Everything

Integrate contract verification into CI/CD pipeline from day one - manual verification won't scale.

4. Document Clear Processes

Create runbooks for common scenarios (contract changes, breaking changes, versioning strategy).

Need Help with Contract Testing?

I can help your team implement contract testing and improve API quality.

Get in Touch