Software Testing, QA Automation & Quality Engineering Master Interview Bank
Test automation pyramids, unit testing vs integration testing, mocking vs stubbing, Playwright & Cypress, contract testing (Pact), and flaky tests.
Curriculum Roadmap & Learning Path
3 StagesPart 1: Basic & Foundational Concepts (Junior / Entry-Level)
13 QuestionsWhat is the difference between Black-Box, White-Box, and Gray-Box Testing?
Black-Box Testing: Testing the system strictly from an external user's perspective without knowledge of the internal code, architecture, or • White-Box Testing (Clear-Box): Testing with full visibility into internal code structure, control flows, loops, and data algorithms • Gray-Box Testing: A hybrid approach.
Explain the Practical Testing Pyramid and Cost vs. Confidence Trade-Offs.
The Testing Pyramid (Martin Fowler / Mike Cohn) structures automated tests by execution speed, maintenance cost, and fidelity.
Unit Testing vs. Integration Testing vs. End-to-End (E2E) Testing.
Dimension Unit Tests Integration Tests End-to-End (E2E) Tests.
Regression Testing vs. Smoke Testing vs. Sanity Testing.
Smoke Testing (Build Verification): A quick, shallow set of tests run immediately after a new build is deployed to verify that critical • Sanity Testing: A focused subset of tests run after a bug fix or minor patch to verify that the specific defect is resolved and no obvious.
What is the AAA (Arrange-Act-Assert) Pattern and Given-When-Then?
A universal standard for writing clean, readable, and maintainable test cases: Arrange (Given): Setup test fixtures, inputs, and mock return values • Act (When): Execute the actual function or method under test • Assert (Then): Verify that the output, state change, or mock invocations match the expected outcome.
Test Doubles Taxonomy: Dummy, Stub, Spy, Mock, and Fake.
According to Gerard Meszaros' taxonomy: Dummy: Objects passed around simply to satisfy function signatures (e.g. filling an unused required argument null or {}) • Stub: Returns hardcoded, predefined responses to calls made during the test.
Understanding Code Coverage Metrics: Line vs. Branch vs. Function vs. Path Coverage.
Line/Statement Coverage: The percentage of executable lines of code executed by tests • Function Coverage: The percentage of declared functions invoked at least once • Branch Coverage: Measures whether every decision branch (e.g., both the if (true) and else (false) paths) was evaluated.
TDD (Test-Driven Development) vs. BDD (Behavior-Driven Development).
TDD (Test-Driven Development) • Developer-centric engineering discipline following the Red-Green-Refactor cycle • Red: Write a failing automated test before writing any implementation code • Green: Write the bare minimum code necessary to make the test pass.
Assertions Deep Dive: Deep Equality vs. Strict Equality and Async Assertions.
Strict Equality (toBe / ===): Compares memory references for objects and values for primitives • Deep Equality (toEqual): Recursively inspects all properties, keys, and values of objects and arrays • Async Assertions: Always await asynchronous expectations.
What is Snapshot Testing, and what are its legitimate use cases vs. anti-patterns?
Snapshot tests serialize a data structure or rendered component tree to a file on disk. Subsequent test runs compare new output against the stored snapshot.: Legitimate Use Cases • Validating complex API JSON schemas or GraphQL AST outputs • Verifying generated code (e.g., compiler outputs, CLI generators) • Anti-Patterns.
Property-Based Testing vs. Example-Based Testing (fast-check / hypothesis).
Example-Based Testing: You hardcode specific inputs and test known outputs: add(2, 3) === 5 • Property-Based Testing (fast-check) • You define mathematical invariants or universal properties that must hold true for all valid inputs.
What are Test Fixtures and Factories (Fishery / FactoryBot)?
Static Fixture Files (user.json): Hardcoded JSON files • Dynamic Factories (fishery): Functions that instantiate valid mock objects with sensible defaults, allowing individual tests to override only.
What makes a test "flaky", and how do you systematically quarantine and fix it?
A flaky test passes or fails unpredictably without any changes to the underlying code.: Primary Causes • Hardcoded sleeps (await sleep(2000) instead of polling or waiting for network events) • Race conditions and non-deterministic concurrency • Shared global state or test execution order dependencies.
Part 2: Core Architecture & Implementation (Mid-Level)
11 QuestionsVitest vs. Jest: Architectural Differences and Performance Benchmarks.
Jest • Designed before modern ES modules (ESM) • Manages its own custom module resolution and mock caches, which adds heavy overhead in modern TypeScript/ESM projects • Vitest.
Why Mock Service Worker (MSW) is superior to module mocking (Axios/Fetch mocks).
Module Mocking (jest.mock('axios')) • Intercepts code inside your application runtime • Couples tests to the specific HTTP client implementation • MSW (Mock Service Worker).
Testing Library Philosophy: Testing User Behavior vs. Implementation Details.
Kent C. Dodds' guiding principle: "The more your tests resemble the way your software is used, the more confidence they can give you.": Implementation Details to Avoid • Testing component state variable names (wrapper.state('isOpen')) • Querying by internal CSS classes (.btn-primary).
Database Testing Strategies: Testcontainers vs. In-Memory SQLite vs. Transaction Rollbacks.
In-Memory SQLite • Risk: SQL dialects differ drastically • Transaction Rollback Pattern • Wrap each test in a database transaction and issue ROLLBACK at the end of the test.
API Testing with Schema Validation (Zod / JSON Schema).
Testing REST APIs should verify both HTTP status codes and contract fidelity.
Playwright vs. Cypress: Architectural Comparison.
Cypress • Executes inside an `` within the same browser tab as the application • Limitations: Limited multi-tab support, cannot automate multiple distinct browser contexts/users simultaneously, restricted cross-domain navigation • Playwright (Microsoft).
Playwright Auto-Waiting and Web-First Assertions: Why `sleep()` is an anti-pattern.
Traditional Selenium tests required arbitrary sleeps (sleep(3000)), causing test suites to take hours while remaining flaky under CI load. Playwright Auto-Waiting: Before clicking, Playwright automatically checks • Is the element attached to the DOM? • Is it visible? • Is it stable (not animating or transitioning)?.
Visual Regression Testing: Pixelmatch, Percy, and Tolerance Thresholds.
Functional tests verify that text exists, but miss layout bugs (e.g. CSS bug hiding a checkout button behind an image or breaking mobile typography).: Visual Regression Testing: Takes screenshot snapshots of rendered pages and computes a pixel-by-pixel diff against a baseline image.
Load Testing with k6: Virtual Users (VUs), Stages, and Thresholds.
k6 is a modern, developer-centric load testing tool written in Go with JavaScript test scripts.
Load Testing Types: Stress, Spike, Soak (Endurance), and Breakpoint Testing.
Smoke Load Test: Minimal load (1-5 VUs) to verify test scripts work against staging • Load Test: Tests system under expected normal peak traffic to verify SLAs • Stress Test: Increases load beyond normal capacity to determine system stability and resource recovery limits.
Automated Accessibility (a11y) Testing with `axe-core` in CI/CD.
Automating WCAG 2.1/2.2 AA compliance checks.
Part 3: Advanced Internals, Scale & Production Quality (Senior / Lead)
26 QuestionsConsumer-Driven Contract Testing with Pact for Microservices.
In a microservices architecture with 50 services, running full E2E environments for every PR is slow, expensive, and fragile. Consumer-Driven Contract Testing (Pact): Consumer Defines Contract: The frontend or downstream service writes unit tests defining the exact request it sends and the minimum response.
Mutation Testing: Killing Mutants with Stryker to Measure Test Suite Quality.
Code coverage measures which lines ran, but not whether tests actually asserted correct behavior. Mutation Testing (stryker): Stryker intentionally introduces small bugs (mutants) into your production code • Changes if (a > b) to if (a >= b) • Changes return true to return false • Removes a function call.
Concurrency and Race Condition Testing Strategies.
Testing that concurrent operations do not cause double-spending or corrupt bank balances.
Chaos Engineering: Fault Injection with Chaos Mesh and LitmusChaos.
Principles of Chaos Engineering (Netflix Simian Army): Rather than waiting for outages in production, proactively inject failure into staging/production to prove resilience • Fault Types • Network Chaos: Introduce 500ms packet latency or 20% packet drop • Pod Kill Chaos: Terminate random database or API pods.
Security Testing: SAST vs. DAST vs. IAST vs. Software Bill of Materials (SBOM).
SAST (Static Application Security Testing - SonarQube, Semgrep): Scans source code repositories for vulnerabilities (SQL injection, hardcoded • DAST (Dynamic Application Security Testing - OWASP ZAP): Attacks running applications from the outside via HTTP, probing for XSS and.
Synthetic Monitoring vs. Real User Monitoring (RUM).
Real User Monitoring (RUM): Captures telemetry (Web Vitals, page load times, JS errors) directly from real human users' browsers in production • Synthetic Monitoring: Automated headless browser scripts (Playwright / Datadog Synthetics) executing critical business workflows (Login -> Add.
CI/CD Test Suite Optimization: Test Sharding and Predictive Test Selection.
As test suites grow to 5,000+ tests taking 45 minutes to execute: Test Sharding (playwright test --shard=1/4) • Predictive Test Selection (Affected Tests).
Mobile E2E Testing Frameworks: Maestro vs. Appium vs. Detox.
Appium: Uses WebDriver protocol • Detox (Wix): Gray-box testing for React Native • Maestro (Mobile.dev - Modern Standard) • Declarative YAML syntax for iOS and Android.
Distributed Load Testing with k6 and Locust.
A single generator machine can only generate ~30,000 requests/second before exhausting host sockets and CPU: Distributed k6 (k6-operator on Kubernetes) • Deploys a custom resource (K6) in Kubernetes that spawns 20 runner pods across worker nodes • Coordinates test execution and aggregates metrics into a single real-time dashboard.
Observability-Driven Testing: Asserting on OpenTelemetry Traces.
Traditional tests assert on HTTP status and response JSON, but miss background side effects (e.g., did the service emit the correct distributed tracing spans or publish an audit log?): Trace-Based Testing (Tracetest) • Uses OpenTelemetry trace graphs as test assertions.
High-Scale Test Data Management: Seeding and Anonymization Pipelines.
Testing against empty databases produces unrealistic query execution plans: Production Database Snapshot Cloning: Take a point-in-time snapshot of production • Automated PII Anonymization: Strip sensitive user data (passwords, emails, phone numbers, credit cards) using automated data scrubbers.
Performance Profiling in Automated Tests: Benchmarking CPU and Memory Regressions.
Catching performance degradations in CI before code merges: Using benchmark harnesses (e.g. tinybench or Vitest bench).
Testing Microfrontends and Cross-Application Integration.
In architectures using Module Federation or independent sub-apps: Test independent microfrontends in isolation using mock host shells • Run targeted cross-application contract tests to verify that shared global event buses, authentication tokens, and shared design system tokens.
End-to-End Test Suite Maintenance: Quarantine, Deprecation, and Flake Budgets.
Maintaining healthy testing culture across 50 engineering teams: Flake Budget SLA: If a team's E2E test suite flake rate exceeds 2%, team feature deployments are paused until flakiness is resolved.
Mocking External Third-Party APIs (Stripe, Twilio, OAuth Providers).
Never call real third-party production APIs during automated test runs!: Use official vendor mock containers (e.g. stripe-mock Docker container) • Or use MSW network interception to simulate edge cases that are difficult to reproduce with real APIs (HTTP 429 Too Many Requests, 504 Gateway.
The 10 Principles of World-Class Enterprise Quality Engineering.
Invert the Testing Iceberg: Prioritize fast unit and integration tests over bloated E2E suites • Never commit hardcoded sleeps: Always use auto-waiting and polling assertions • Isolate Test State: Every test must be completely independent and runnable in parallel • Test User Behavior, Not Implementation Details.
Visual Regression Testing: Pixel-by-pixel diffing vs DOM snapshot testing.
DOM Snapshots (Jest): Serializes HTML string output • Visual Regression Testing (Playwright / Percy / Applitools) • Captures full-page screenshots of pages or isolated components in headless Chromium/Firefox/WebKit • Compares screenshots against a baseline image using pixel-diffing algorithms (e.g. pixelmatch).
Property-Based Testing: Fuzzing algorithms with fast-check to discover hidden edge cases.
Instead of testing a few hand-crafted example inputs (add(2, 3) == 5), Property-Based Testing tests universal mathematical invariants across thousands of randomized inputs.
Test Data Management (TDM): Synthetic data generation (Faker.js), Factories, and database state resetting.
Tests that share or mutate hardcoded database seed data cause order-dependent flakiness: Factory Pattern (e.g. Fishery / FactoryBot): Dynamically generates realistic domain objects with sensible defaults.
Sharding and Parallelization in Playwright: Test distribution across multiple CI machines.
When an E2E test suite takes 40 minutes to run sequentially on one machine: Playwright Native Sharding: Split the test suite evenly across N parallel CI runners.
Mobile App Automated Testing: Appium vs Maestro.
Automating native iOS and Android user interaction: Appium (Legacy): Uses the WebDriver protocol • Maestro (Modern Native Mobile Automation) • Declarative YAML test definitions.
API Fuzzing & Security Scanning with OWASP ZAP in CI/CD.
Automated Dynamic Application Security Testing (DAST) in CI: OWASP ZAP (Zed Attack Proxy): Runs in a Docker container in staging pipelines • Spiders web applications and ingests OpenAPI/Swagger specifications • Injects security attack vectors (SQL Injection payloads, Cross-Site Scripting ``, Header injection, Path Traversal).
Testing Asynchronous Event-Driven Architectures: Validating Kafka / RabbitMQ consumer processing.
Testing distributed systems where publishers and consumers communicate asynchronously over message brokers: Producer publishes OrderCreated event to Kafka (running via Testcontainers) • Polling Assertions: Never use sleep(5000)!.
Database Migration Testing: Automated forward migration and rollback validation.
Broken database migrations in production cause multi-hour downtime: Automated Migration Test in CI • Spin up a fresh ephemeral PostgreSQL container with previous schema version • Execute all forward migrations (up): Verify all tables, indices, and foreign keys build successfully.
Webhook and Asynchronous Callback Testing: Simulating inbound payloads and signature verification.
Testing that your API correctly handles webhook callbacks (e.g. Stripe payment_intent.succeeded, GitHub webhooks): Use helper utilities to generate the cryptographic HMAC signature header (stripe-signature).
Measuring Test Suite Health & Developer Experience: Key engineering metrics.
Tracking the business ROI and developer experience of the QA engineering organization: Flakiness Rate: Percentage of test runs that fail on main and succeed on immediate rerun with zero code changes (target 75%).