Assertions and Behavior Verification Questions

Choosing what to assert and how to verify behavior meaningfully. Covers assertion strategy, verifying observable behavior over implementation detail, avoiding weak or over-specified assertions, and using assertion libraries effectively. Emphasizes assertions that fail for the right reasons and give a clear diagnosis.

HardTechnical
76 practiced

Describe how you would write tests and assertions for a training pipeline that implements differential privacy (DP): verifying per-step gradient clipping, noise injection with expected scale, and tracking the privacy budget (epsilon). What tooling or automated checks would you include to prevent accidental removal of DP protections?

EasyTechnical
78 practiced

Write a pytest parameterized unit test for a tokenizer function tokenize(text: str) -> List[str] that must handle: normal sentence, empty string, strings with multiple spaces, strings with emojis, and invalid (non-string) inputs. Show how you would assert both correctness and descriptive messages for failures.

HardTechnical
76 practiced

You are a staff AI engineer asked to improve overall testing culture for AI teams. Create a proposal including a 6-month roadmap: training topics, metrics to track (flake rate, test coverage, mean time to detect), incentives, CI gating policies, and how to scale testing infrastructure. Include short-term wins and long-term investments.

HardTechnical
89 practiced

Write a Hypothesis-based fuzz test for a tokenizer that must not crash for arbitrary Unicode input and must normalize certain characters. Provide a concise Hypothesis test that generates a variety of Unicode strings and asserts the tokenizer returns a list of tokens and does not raise exceptions.

MediumTechnical
73 practiced

Golden file tests record canonical outputs and compare future outputs against them. Discuss advantages and disadvantages of golden files for model outputs and propose at least two alternative approaches (e.g., tolerance-based, property-based checks) with examples when they are more appropriate.

Unlock Full Question Bank

Get access to all 40 Assertions and Behavior Verification interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.