Bird
0
0

You want to test a REST API that returns different responses based on user roles. How can you model this in contract testing?

hard📝 Application Q8 of 15
Rest API - API Testing and Monitoring
You want to test a REST API that returns different responses based on user roles. How can you model this in contract testing?
AIgnore roles and test only the default response
BUse one interaction with multiple response bodies combined
CTest roles only in UI tests, not in contract tests
DCreate separate interactions with different provider states for each user role
Step-by-Step Solution
Solution:
  1. Step 1: Understand provider states in contract testing

    Provider states allow simulating different backend conditions like user roles.
  2. Step 2: Model role-based responses

    Create separate interactions with distinct provider states for each role to test their specific responses.
  3. Final Answer:

    Create separate interactions with different provider states for each user role -> Option D
  4. Quick Check:

    Use provider states for role-based responses [OK]
Quick Trick: Use provider states to simulate different user roles [OK]
Common Mistakes:
MISTAKES
  • Trying to combine multiple responses in one interaction
  • Ignoring role differences in contract tests
  • Assuming UI tests cover API contract for roles

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes