Interview Q&A · questions with model answers

Testing Interview Questions

Part of the study plan for: Backend Engineer · QA Engineer / SDET · Frontend Engineer · Full Stack Engineer

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked What makes a good unit test?

    A good unit test is fast, deterministic, isolated, and readable; it tests one behavior through the public interface, has a descriptive name, follows Arrange-Act-Assert, and fails for exactly one…

  2. Most asked How do you write reliable integration tests that use a database?

    Run the real database engine (via Testcontainers or a CI service container), apply migrations, isolate each test (transaction rollback, truncation, or unique data), and seed data with factories…

  3. Most asked What causes flaky tests and how do you fix them?

    Flaky tests pass and fail without code changes. Common causes: timing and race conditions, shared state between tests, test order dependence, real network or time dependencies, randomness, and…

  4. How do you test code that depends on the current time or randomness?

    Inject a clock or random source instead of calling now() or random() directly, or use libraries to freeze time (freezegun/time-machine, Sinon fake timers, Java Clock). Seed random generators for…

  5. How do you test code that calls external HTTP services?

    Wrap the external API behind an interface and test your logic with fakes; test the client adapter itself against recorded or stubbed HTTP (respx, nock, MSW, WireMock), including error responses,…

  6. How should you test frontend components?

    Test components the way users interact with them: render, find elements by role/label/text, simulate events, and assert on visible output (Testing Library). Mock network calls at the HTTP layer…

  7. How do you test an API, and what would you automate?

    Test the contract (status codes, schema, headers), the business rules (valid and invalid inputs, boundaries, permissions), error handling, idempotency and concurrency, and non-functional aspects…

  8. How do you approach performance and load testing?

    Define goals first (for example p95 under 300 ms at 2,000 requests per second with under 0.1% errors), model realistic traffic (user journeys, think time, data variety), run tests against a…

  9. How do you manage test data for automated tests?

    Each test should create the data it needs (through APIs, factories or fixtures) and not depend on shared, mutable records. Use seeded reference data for things that rarely change, synthetic or…

  10. What should block a release, and how do you report quality to stakeholders?

    Agree on objective release criteria in advance: all automated checks green, no open critical or high-severity defects in the release scope, performance and security checks within limits, and key…

  11. How do you test a feature behind a feature flag?

    Test both states: the new behaviour with the flag on and the existing behaviour with it off, plus the switch between them if users can be mid-flow. Automated tests should set flags explicitly…

  12. How do you integrate automated tests into a CI/CD pipeline?

    Run fast checks (lint, unit tests) on every push, integration and contract tests on every pull request, end-to-end smoke tests after deploying to a test environment, and broader suites (full…

  13. How should you manage test data?

    Create data per test with factories or builders that provide sensible defaults and let tests override only what matters (factory_boy, Faker, Instancio). Avoid large shared fixtures that couple many…

  14. How do you test asynchronous code?

    Use your framework's async support (pytest-asyncio/anyio, async test functions in Vitest/Jest, JUnit with Awaitility), await results rather than sleeping, and use fake timers for timeouts and retries.

  15. How do you prevent regressions when fixing bugs?

    Write a test that reproduces the bug and fails, fix the code until it passes, and keep the test in the suite. Also check whether the same bug class exists elsewhere and add guards (types,…

  16. How do you include security testing in development?

    Use SAST (static analysis), dependency/SCA scanning, secret scanning and DAST (dynamic scans like OWASP ZAP) in CI; write tests for authorization rules (user A can't access user B's data) and input…

  17. How do you add tests to legacy code that wasn't designed for testing?

    Start with characterization tests that capture current behavior (even if wrong) at a high level, then introduce seams (dependency injection, extracting functions, wrapping globals) to make smaller…

  18. How do you test code behind feature flags?

    Test both flag states for the code paths that differ, keep flag evaluation injectable so tests can force a state, and remove flags (and their tests) after full rollout to avoid combinatorial growth.

  19. How do you test accessibility?

    Combine automated checks (axe in unit/E2E tests, Lighthouse) that catch about a third of issues with manual testing: keyboard-only navigation, screen readers (NVDA, VoiceOver), zoom and contrast,…

Was this page helpful?

Report a mistake