InterviewStack.io LogoInterviewStack.io

Testability and Testing Practices Questions

Emphasizes designing code for testability and applying disciplined testing practices to ensure correctness and reduce regressions. Topics include writing modular code with clear seams for injection and mocking, unit tests and integration tests, test driven development, use of test doubles and mocking frameworks, distinguishing meaningful test coverage from superficial metrics, test independence and isolation, organizing and naming tests, test data management, reducing flakiness and enabling reliable parallel execution, scaling test frameworks and reporting, and integrating tests into continuous integration pipelines. Interviewers will probe how candidates make code testable, design meaningful test cases for edge conditions, and automate testing in the delivery flow.

EasyTechnical
90 practiced
Explain how you design machine learning code for testability. Describe dependency injection and creating seams for mocking, and explain concretely how you would refactor a typical training script that tightly couples data loading, preprocessing, model creation, and training loop so each piece can be unit tested. Provide Python-level patterns or function signatures you would use (no full implementation required).
HardTechnical
82 practiced
You must write automated tests for a streaming ML pipeline that computes sliding-window aggregates and handles late-arriving events with watermarking. Describe how to simulate streaming input, late events, and window triggers in tests and what assertions you would make about correctness and window semantics.
MediumTechnical
134 practiced
Write a unit test in NumPy that performs a small numerical gradient check for a custom loss function implemented as `loss(x)`. Provide the test logic (finite difference approximation) and explain acceptable tolerance choices for floating point comparisons.
EasyTechnical
122 practiced
Write a short pytest fixture that creates an isolated temporary directory for a test that writes model artifacts and ensures cleanup. Name the fixture and show how a test would use it. Focus on clarity and test isolation rather than full implementation details.
HardTechnical
89 practiced
Leadership: You are the ML engineering lead and data scientists are reluctant to write tests because experiments change rapidly. How would you advocate for and introduce sustainable testing practices that do not slow down experimentation? Outline a rollout plan, training, and quick wins that demonstrate value.

Unlock Full Question Bank

Get access to hundreds of Testability and Testing Practices interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.