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.

MediumTechnical
71 practiced

An API returns a list of items but the backend does not guarantee ordering. In Python (pytest), show how you would write assertions that verify the API response contains exactly the set of expected items regardless of order and also validate per-item attributes. Provide concise example code or pseudo-code.

EasyTechnical
112 practiced

What logging and assertion practices should automated tests follow to maximize diagnosability when failures occur? Provide examples of useful structured log content, what context to include (e.g., test id, request/response), and guidance on assertion granularity and failure messages.

MediumTechnical
73 practiced

Explain the difference between soft assertions (collecting multiple failures in a test) and hard assertions (failing immediately). When is it appropriate to use soft assertions in UI tests? Show how you would implement soft assertions in pytest or TestNG and discuss trade-offs regarding debugging and flakiness.

EasyTechnical
87 practiced

Explain the Arrange-Act-Assert (AAA) testing pattern. Provide two concrete examples that explicitly label Arrange, Act, and Assert: one unit test (choose Python or Java) and one UI end-to-end test (choose Selenium, Playwright, or Cypress). Explain why AAA improves readability and maintainability.

That is every published Assertions and Behavior Verification question for QA Engineer so far. Browse the other topics in this category, or practice this one interactively.