Interview Q23: What is the difference between unit tests and AI evals?

Unit tests check deterministic code such as validators and authorization. AI evals assess model-dependent outcomes against criteria, often with human or automated grading. Both are needed.

Interview structure: define the concept, explain the design trade-off, and give one production example.

Note

Interview approach: explain the concept, show the control boundary, and discuss the failure mode.

Minimal illustration
// Example: validate a boundary before doing work.
function requireNonEmptyString(value) {
  if (typeof value !== "string" || value.trim() === "") {
    throw new Error("Expected a non-empty string");
  }
  return value;
}
💡 The snippet demonstrates a general boundary-validation principle. Adapt the example to the concept and explain how the application enforces the rule at runtime.
Key Takeaways
  • State the concept clearly.
  • Mention one limitation or failure mode.
  • Connect it to a production decision.
Knowledge Check

What is best tested with a deterministic unit test?