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.

EasyTechnical
0 practiced
Flaky tests are a common pain in ML projects. Describe what makes a test flaky in AI contexts (examples: nondeterministic initialization, external data/service variability, timing), and outline a triage checklist you would follow immediately when encountering a flaky test in CI.
EasyTechnical
0 practiced
You have a simple PyTorch model's forward method below. Write minimal tests (using pytest) asserting output shape, dtype, that values are finite (no NaN/Inf), and that a forward pass with `torch.no_grad()` does not require gradients.
python
import torch
import torch.nn as nn

class SimpleModel(nn.Module):
    def __init__(self, in_dim, out_dim):
        super().__init__()
        self.lin = nn.Linear(in_dim, out_dim)
    def forward(self, x):
        return self.lin(x)
Specify the test inputs and assertions.
HardTechnical
0 practiced
A third-party tokenization library update caused a subtle regression in downstream model outputs. Describe how you would write tests to protect against such indirect dependency regressions in the future. Include ideas like pinned contracts, fuzz/regression suites, and integration tests that cover end-to-end tokenization behavior.
MediumTechnical
0 practiced
An NLP pipeline tokenizes text, encodes to IDs, decodes back, and detokenizes. Design end-to-end tests that validate round-trip consistency for a set of edge-case inputs (combining accents, emojis, punctuation, whitespace). Provide test examples and explain what assertions you would use to avoid brittle tests.
HardTechnical
0 practiced
Design tests that verify model calibration (reliability): implement a test that computes reliability diagrams and Expected Calibration Error (ECE) on a validation slice and assert a maximum allowed ECE threshold. Describe how to choose binning strategy, sample size requirements, and how to handle class imbalance.

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.