Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
ProgrammingMiddleOccasionalRisk analysis

Which risks and test oracles matter most for error handling with inputs from an untrusted API?

Answer

Prioritize the risks that could invalidate the user or business outcome before making inputs, outputs, ownership and failure behavior explicit before choosing an implementation. Focus on error handling with inputs from an untrusted API. Use small deterministic units plus integration behavior at real boundaries as the oracle. Cover normal flow, invalid inputs, exceptions, concurrency and resource cleanup. Keep data and dependencies controlled enough to reproduce failures. Release only when tests fail for one understandable reason and the code remains easy to change.

Strong answer includes

  • explicit risk and test oracle for error handling
  • controls side effects and dependencies
  • designs for deterministic tests
  • measurable evidence and residual-risk statement

Practical example

A weather API occasionally returned a 200 status with an error message in the body instead of a proper error code, and the client's error handling only checked the status code, so it displayed garbage temperature data to users. The key risk flagged was trusting the transport-layer status over payload validation, with the oracle being a test that feeds exactly that malformed 200 response and asserts the client treats it as an error.

#programming#test-code#error-handling

Sources

Git referenceGit Project · Version control concepts and commandsPlaywright best practicesMicrosoft · Reliable modern browser automationMDN JavaScript GuideMozilla · Functions, closures, objects, classes, error handling and asynchronous programming (promises, async/await)