Assertions and Behavior Verification Questions

Choosing what to assert and how to verify behavior meaningfully. Covers assertion strategy, verifying observable behavior over implementation detail, avoiding weak or over-specified assertions, and using assertion libraries effectively. Emphasizes assertions that fail for the right reasons and give a clear diagnosis.

EasyTechnical
68 practiced

Explain the differences between unit tests and integration tests in the context of a backend web service. Give concrete examples of what you would test at each level, discuss trade-offs (speed, flakiness, maintenance), and explain when you would run a test with a real database versus a mocked one in CI.

EasyTechnical
126 practiced

Given this Python function:

python
def is_palindrome(s):
    return s == s[::-1]

Write pytest unit tests that exercise normal, edge, boundary, and invalid inputs (include '', 'a', 'aa', 'aba', 'ab', None, unicode strings, and long strings). Use parametrized tests and include descriptive assertion messages to make failures easy to debug.

MediumTechnical
73 practiced

Explain golden master or snapshot testing for a module that outputs nested JSON. Describe how to create golden files, how to mask or normalize nondeterministic fields such as timestamps or ids, how to version golden files, and the safe review process to update goldens when intended changes occur.

HardTechnical
63 practiced

Design a strategy for non-deterministic performance testing where noise from environment is high. Explain sample collection, statistical tests to detect regressions, baseline management, automated comparisons for PRs, and how to minimize false positives using confidence intervals and repeated runs.

MediumSystem Design
81 practiced

Design a CI pipeline for a React + Node application that runs unit, integration, and UI tests. Include parallelization strategy, test result caching, artifact storage, flaky-test detection, gating rules for PR merges, and techniques to reduce CI time without sacrificing confidence.

Unlock Full Question Bank

Get access to all 41 Assertions and Behavior Verification interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.