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.

HardTechnical
63 practiced
Propose an approach to generate adversarial examples as part of CI to test robustness while keeping runtime manageable. Describe fast attack methods (e.g., FGSM), sampling strategies (small seed set), and fail criteria (e.g., drop in accuracy beyond epsilon). Explain how to avoid flakiness and limit compute.
HardTechnical
62 practiced
Design an automated process that creates a reproducible minimal failing example for flaky or failing training jobs. Describe what artifacts to capture (seed, code commit hash, small dataset slice, model checkpoint, environment), how to reduce size of artifacts, and an automated script that attempts to reproduce and validate the problem.
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.
MediumTechnical
45 practiced
Multiple assertions in a single test can hide the true cause of failure. Describe techniques and patterns (e.g., pytest subtests/parametrization, small single-concern tests, assertion aggregation) you would use to ensure failure isolation and maintainable tests. Provide a short code example demonstrating one pattern.
HardTechnical
46 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.

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.