← Back to libraryQuestion 195 of 273
🌐API TestingIntermediate

Test Data Management and Coverage

📌 Definition:

Managing test data effectively and ensuring all API functionality is covered by comprehensive testing.

📖 Detailed Explanation:

Test data includes input values, expected outputs, and database state. Test coverage measures what percentage of API is tested. Higher coverage generally means fewer production defects, but 100% is not always practical. Focus on critical paths.

📎 Coverage Types:
TypeDescriptionTarget
Endpoint CoverageAll endpoints tested100%
Scenario CoverageHappy path + error cases + edge cases80-90%
Data CoverageValid, invalid, boundary values tested75%+
Code CoverageSource code executed by tests70-80%
📎 Test Data Guidelines:
  • Use realistic test data following business rules
  • Ensure test data isolation - each test uses unique data
  • Never use real production data in tests
  • Reset database between test runs for consistency
  • Create test data builders for reusability
🎯 Scenario-Based Interview Question:

Scenario: You're testing an online shopping cart API. Your team has written 200 test cases but the API still has bugs in production that weren't caught during testing. Analysis shows the test coverage is: endpoint_coverage=95%, scenario_coverage=65%, data_coverage=40%. Your manager asks: 'Why are bugs escaping to production despite high endpoint coverage?' Provide analysis and propose a solution to improve test quality.