0
0
Microservicessystem_design~20 mins

Contract testing (Pact) in Microservices - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pact Contract Testing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the Purpose of Contract Testing with Pact

Which of the following best describes the primary purpose of using Pact in microservices?

ATo monitor live traffic between microservices in production environments.
BTo perform load testing on microservices to check their performance under stress.
CTo automate UI testing of microservices' front-end interfaces.
DTo verify that the interactions between a service consumer and provider meet a shared contract without deploying the services.
Attempts:
2 left
💡 Hint

Think about what contract testing ensures between two services before they communicate.

Architecture
intermediate
2:00remaining
Key Components in a Pact Contract Testing Setup

Which component is responsible for generating the contract file in a Pact testing setup?

AThe API gateway generates the contract by intercepting traffic.
BThe service provider publishes the contract after running its tests.
CThe service consumer generates the contract during its tests.
DA separate contract registry automatically creates contracts from API definitions.
Attempts:
2 left
💡 Hint

Consider which side defines the expected interactions first.

scaling
advanced
3:00remaining
Scaling Contract Testing in a Large Microservices Environment

In a system with 50 microservices, each with multiple consumers and providers, what is the best approach to manage Pact contract testing efficiently?

ASkip contract testing for less critical services to reduce overhead.
BCentralize all contracts in a shared Pact Broker and automate verification pipelines for each service.
CEach team manually shares contract files via email and runs tests locally before deployment.
DUse a single monolithic contract file for all services to simplify management.
Attempts:
2 left
💡 Hint

Think about automation and centralization for large-scale coordination.

tradeoff
advanced
3:00remaining
Tradeoffs of Using Contract Testing vs. End-to-End Testing

Which statement best describes a tradeoff when choosing Pact contract testing over full end-to-end testing?

AContract testing provides faster feedback and isolates integration issues but may miss UI or infrastructure problems caught by end-to-end tests.
BContract testing is slower and more expensive than end-to-end testing but provides better UI coverage.
CContract testing replaces the need for any other testing types, including unit and integration tests.
DContract testing requires deploying all services together, increasing complexity compared to end-to-end testing.
Attempts:
2 left
💡 Hint

Consider what contract testing focuses on versus what end-to-end testing covers.

estimation
expert
3:00remaining
Estimating Pact Contract Test Execution Time in CI Pipeline

You have 20 microservices, each with 5 consumers. Each Pact verification test takes 10 seconds. Assuming all tests run sequentially, estimate the total Pact verification time in the CI pipeline.

A1000 seconds
B6000 seconds
C1500 seconds
D3000 seconds
Attempts:
2 left
💡 Hint

Calculate total tests as number of microservices × consumers, then multiply by test time.