InterviewStack.io LogoInterviewStack.io

Software Testing and Assertions Questions

Core software testing and debugging practices, including designing tests that exercise normal, edge, boundary, and invalid inputs, writing clear and maintainable unit tests and integration tests, and applying debugging techniques to trace and fix defects. Candidates should demonstrate how to reason about correctness, create reproducible minimal failing examples, and verify solutions before marking them complete. This topic also covers writing effective assertions and verification statements within tests: choosing appropriate assertion methods, composing multiple assertions safely, producing descriptive assertion messages that aid debugging, and structuring tests for clarity and failure isolation. Familiarity with test design principles such as test case selection, test granularity, test data management, and test automation best practices is expected.

MediumTechnical
0 practiced
Describe how you would implement a CI check that enforces that any source file touching model training/inference must have corresponding tests (e.g., `tests/test_*.py`). Outline a simple script or CI job that fails the build when missing tests are detected, and discuss false positives and ways to make it robust.
EasyTechnical
0 practiced
Given a small function that computes recall:
python
def recall(y_true, y_pred):
    # y_true, y_pred: lists/arrays of 0/1
    tp = sum(1 for t, p in zip(y_true, y_pred) if t == 1 and p == 1)
    fn = sum(1 for t, p in zip(y_true, y_pred) if t == 1 and p == 0)
    return tp / (tp + fn)
Write unit tests that check correct values, handle division-by-zero, and include messages describing the failing scenario (e.g., "expected recall 0.75 for case X but got Y"). Use pytest.
MediumSystem Design
0 practiced
Outline an integration test that validates an end-to-end retraining workflow: data ingestion, preprocessing, training (on small sample), model packaging, deployment to a staging inference endpoint, and a prediction sanity check. For each stage, list the artifacts to assert, how to isolate failures, and how to make the test repeatable and fast.
MediumSystem Design
0 practiced
Design integration tests for an inference microservice that hosts a transformer model. Requirements: max sequence length 1024, expected p95 latency < 100ms for batch size 1 on a GPU, correctness of outputs for a set of canonical prompts, and graceful error handling for invalid inputs. Describe the test types (unit/integration/perf), tools you'd use, and failure isolation strategies.
EasyTechnical
0 practiced
Explain property-based testing and show a concise Hypothesis example that tests a text-normalization function `normalize_text(s: str) -> str` for properties: idempotence (normalizing twice yields same result) and that output contains no control characters. Provide Hypothesis strategies you would use.

Unlock Full Question Bank

Get access to hundreds of Software Testing and Assertions interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.