Bird
0
0

If a Pact contract specifies a JSON response with a field "name" as a string, what happens if the provider returns a number instead?

medium📝 Analysis Q5 of 15
Microservices - Testing Microservices
If a Pact contract specifies a JSON response with a field "name" as a string, what happens if the provider returns a number instead?
APact Verifier will pass the test
BPact Verifier will fail the test due to type mismatch
CPact Verifier ignores data types by default
DPact Verifier only checks status codes
Step-by-Step Solution
Solution:
  1. Step 1: Understand Pact's type checking

    Pact verifies that response fields match expected types defined in the contract.
  2. Step 2: Identify mismatch impact

    Returning a number instead of a string causes a type mismatch, failing the test.
  3. Final Answer:

    Pact Verifier will fail the test due to type mismatch -> Option B
  4. Quick Check:

    Type mismatch = Test fails [OK]
Quick Trick: Data types must match exactly in Pact contracts [OK]
Common Mistakes:
  • Assuming Pact ignores types
  • Thinking only status codes matter
  • Believing Pact auto-converts types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes