InterviewStack.io LogoInterviewStack.io

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
78 practiced

Explain the difference between mocks, stubs, fakes, and spies. For each test double give a short example (language-agnostic) and describe a scenario where you would prefer that double to a real dependency in a unit test.

HardTechnical
88 practiced

Design a testing approach to prevent SQL injection across a web application's stack. Include unit tests for query-building logic, integration tests that verify ORM parameterization, fuzzing approaches, static analysis tools to detect unsafe patterns, and test cases for edge inputs that might bypass naive sanitizers.

HardSystem Design
64 practiced

Your repository has a test suite that takes hours to run. Design an optimization plan including test selection strategies (change-based), dependency-aware test impact analysis, parallelization across workers, caching test results/artifacts, splitting tests by risk, and incremental runs for pull requests. Discuss trade-offs and rollout strategy.

HardTechnical
73 practiced

A CI test fails intermittently under load but passes locally. Propose a systematic debugging plan to determine whether the problem is test flakiness, infrastructure instability, a race condition, or timing. Include what telemetry to collect, how to reproduce locally, and steps to isolate and fix the root cause.

HardTechnical
131 practiced

For a C++ low-level module, design a test plan to validate memory safety and undefined behavior. Include unit tests with AddressSanitizer and UndefinedBehaviorSanitizer, fuzzing harnesses for public APIs, CI integration of sanitizers, and an example unit test that would trigger a common UB such as signed integer overflow or out-of-bounds access to validate the sanitizer catches it.

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.