API API Test Automation 2 — Questions and Answers
Question 1: What is the purpose of environment variables in API test automation frameworks?
- Speed up test execution
- Store configuration like base URLs and credentials outside test code (Correct answer)
- Define test assertions
- Generate API documentation
Correct answer: Store configuration like base URLs and credentials outside test code
Environment variables externalize configuration so the same test suite can run against dev, staging, or production without code changes.
Question 2: What does 'contract testing' verify in a microservices API architecture?
- API response times meet SLAs
- Consumer and provider agree on the API interface format (Correct answer)
- All API endpoints are secured
- The API handles load correctly
Correct answer: Consumer and provider agree on the API interface format
Contract testing ensures the API's actual responses conform to the agreed contract the consumer depends on, catching breaking changes early.
Question 3: Which assertion type verifies that an API response matches a predefined JSON structure?
- Status code assertion
- Response time assertion
- Schema validation assertion (Correct answer)
- Header assertion
Correct answer: Schema validation assertion
Schema validation assertions verify the response body conforms to a defined JSON Schema, ensuring correct field names, types, and required properties.
Question 4: What is 'test chaining' in API automation tools like Postman?
- Running tests in alphabetical order
- Passing data from one API request's response to a subsequent request (Correct answer)
- Linking test scripts to documentation
- Chaining multiple assertions in one test
Correct answer: Passing data from one API request's response to a subsequent request
Test chaining extracts values (like an auth token or ID) from one request's response and injects them as inputs to the next request in the flow.
Question 5: What is the role of a 'test report' generated by an API automation framework?
- Document API endpoints for developers
- Provide a human-readable summary of test results, pass/fail status, and errors (Correct answer)
- Generate load test scenarios
- Store API response bodies
Correct answer: Provide a human-readable summary of test results, pass/fail status, and errors
Test reports summarize which tests passed or failed, error messages, and test coverage, helping teams quickly assess API quality after a test run.
Question 6: What does 'negative testing' mean in API test automation?
- Testing only failure scenarios to find crashes
- Sending invalid inputs to verify the API handles errors gracefully (Correct answer)
- Turning off the server during tests
- Testing with no authentication
Correct answer: Sending invalid inputs to verify the API handles errors gracefully
Negative testing sends invalid, missing, or malformed inputs to verify the API returns appropriate error responses rather than crashing or exposing data.
What is the purpose of environment variables in API test automation frameworks?