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.

MediumSystem Design
49 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.
HardTechnical
54 practiced
Propose a comprehensive testing methodology to evaluate fairness and bias in an AI model. Include dataset sampling strategies, statistical tests (e.g., t-tests, KS-test), group-wise metrics (TPR/FPR parity), counterfactual testing, and how to express assertions in tests that can be run in CI without too many false alarms.
HardTechnical
64 practiced
Mutation testing can reveal weaknesses in a test suite. Propose a mutation testing strategy for an ML codebase: define meaningful mutation operators (e.g., flip label, zero-out gradients, change activation), describe how to run mutations efficiently, and explain how to interpret mutation score and prioritize improvements.
EasyTechnical
47 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
63 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.