SDET interview questions on test strategy, the test pyramid, framework architecture and design patterns, contract testing, mocking, metrics and flakiness at scale.
50 questions15 Beginner20 Intermediate15 Advanced
Hands-On SDET Labs
Practice API Test Automation & Contract Testing
Master OAuth token lifecycles, JSON schema validation, and downstream service mocking in our zero-setup online sandbox.
An SDET is a developer focused on testability and quality engineering: building frameworks, tools, and tests across unit, API, and UI layers, and influencing design. A QA automation engineer typically focuses more on automating functional test cases.
Key points
SDETs write production-quality code and review developer code
Own CI quality gates and test infrastructure
Work closer to architecture and developer workflows
An SDET is a developer focused on testability and quality engineering: building frameworks, tools, and tests across unit, API, and UI layers, and influencing design. A QA automation engineer typically focuses more on automating functional test cases.
Answer
The test pyramid recommends many fast unit tests at the base, fewer integration or API tests in the middle, and a small number of end-to-end UI tests on top. Lower layers are faster, cheaper, and less flaky.
Push each check to the lowest layer that can catch it
Interview tip: Follow-up: how would you move a slow UI suite down the pyramid? Identify validations that can become API or component tests.
The test pyramid recommends many fast unit tests at the base, fewer integration or API tests in the middle, and a small number of end-to-end UI tests on top. Lower layers are faster, cheaper, and less flaky.
Answer
I start from business risks and architecture, then define which test types run at which layer, the tools, environments, data approach, CI gates, and quality metrics. It should be a living document agreed with dev and product.
Key points
Scope, risks, test levels and types
Automation approach and tooling
Environments, test data, entry/exit criteria
Metrics and reporting
I start from business risks and architecture, then define which test types run at which layer, the tools, environments, data approach, CI gates, and quality metrics. It should be a living document agreed with dev and product.
Answer
Shift-left means moving quality activities earlier: reviewing requirements and designs, writing tests alongside code, running fast checks on every commit, and defining acceptance criteria before development.
Key points
Three amigos sessions and BDD examples
Unit, contract, and static analysis in pull requests
Shift-right complements it with monitoring and production testing
Shift-left means moving quality activities earlier: reviewing requirements and designs, writing tests alongside code, running fast checks on every commit, and defining acceptance criteria before development.
Answer
A stub returns canned responses, a mock also verifies how it was called, and a fake is a working lightweight implementation such as an in-memory database. A spy wraps a real object and records interactions.
java
PaymentGateway gateway = Mockito.mock(PaymentGateway.class);
when(gateway.charge(100)).thenReturn(true); // stubbing
OrderService service = new OrderService(gateway);
service.placeOrder(100);
verify(gateway, times(1)).charge(100); // mock verification
A stub returns canned responses, a mock also verifies how it was called, and a fake is a working lightweight implementation such as an in-memory database. A spy wraps a real object and records interactions.
Answer
Each class has one responsibility, like page objects for UI, clients for APIs, and builders for data. Frameworks depend on interfaces such as a driver factory so implementations can be swapped without changing tests.
Key points
Single responsibility: no assertions inside page objects
Open/closed: add browsers via new factory implementations
Dependency inversion: inject clients and config
Each class has one responsibility, like page objects for UI, clients for APIs, and builders for data. Frameworks depend on interfaces such as a driver factory so implementations can be swapped without changing tests.
Answer
Shared environments cause data collisions, unstable deployments, and version drift between services. Ephemeral environments per pull request, containerised dependencies, and service virtualisation reduce these problems.
Key points
Testcontainers for databases and brokers
Infrastructure as code for reproducible envs
Health checks before test runs
Shared environments cause data collisions, unstable deployments, and version drift between services. Ephemeral environments per pull request, containerised dependencies, and service virtualisation reduce these problems.
Answer
Page Object and Screenplay for UI abstraction, Factory for driver creation, Builder for test data, Singleton or ThreadLocal for config and drivers, and Strategy for switching execution targets.
java
public class UserBuilder {
private String name = "Test User";
private String role = "customer";
public UserBuilder withRole(String role) { this.role = role; return this; }
public User build() { return new User(name, role); }
}
User admin = new UserBuilder().withRole("admin").build();
Interview tip: Be ready to explain why a plain Singleton WebDriver breaks parallel runs.
Page Object and Screenplay for UI abstraction, Factory for driver creation, Builder for test data, Singleton or ThreadLocal for config and drivers, and Strategy for switching execution targets.
Answer
Contract testing verifies that a consumer and provider agree on the API shape without running both together. With consumer-driven tools like Pact, the consumer publishes expectations and the provider verifies them in its own pipeline.
Key points
Ideal for microservices with independent deployments
Faster and more stable than end-to-end integration tests
Pact Broker plus can-i-deploy as a release gate
Does not replace functional testing of the provider
Contract testing verifies that a consumer and provider agree on the API shape without running both together. With consumer-driven tools like Pact, the consumer publishes expectations and the provider verifies them in its own pipeline.
Answer
I virtualise the dependency with a tool like WireMock, returning realistic responses including errors and delays. This lets us test edge cases like timeouts and 500s that are hard to trigger with the real service.
I virtualise the dependency with a tool like WireMock, returning realistic responses including errors and delays. This lets us test edge cases like timeouts and 500s that are hard to trigger with the real service.
Answer
Load testing checks behaviour at expected traffic, stress testing pushes beyond limits to find the breaking point, spike testing applies sudden bursts, and soak testing runs a steady load for hours to find leaks.
import http from "k6/http";
import { check } from "k6";
export const options = {
vus: 50,
duration: "5m",
thresholds: { http_req_duration: ["p(95)<500"] },
};
export default function () {
const res = http.get("https://test.example.com/api/products");
check(res, { "status is 200": (r) => r.status === 200 });
}
Load testing checks behaviour at expected traffic, stress testing pushes beyond limits to find the breaking point, spike testing applies sudden bursts, and soak testing runs a steady load for hours to find leaks.
Answer
I track defect leakage to production, flaky test rate, pipeline duration, change failure rate, and mean time to detect and recover. Coverage is useful as a signal, not a target.
Key points
DORA metrics connect testing to delivery
Escaped defects by severity and root cause
Avoid vanity metrics like raw test count
I track defect leakage to production, flaky test rate, pipeline duration, change failure rate, and mean time to detect and recover. Coverage is useful as a signal, not a target.
Answer
I check that tests are independent, readable, assert meaningful behaviour, use the right layer, and avoid hard waits or hardcoded data. Test code is held to the same standards as production code.
Key points
One clear reason to fail per test
No sleeps, no order dependency
Meaningful names and assertion messages
Reuse helpers instead of duplicating
I check that tests are independent, readable, assert meaningful behaviour, use the right layer, and avoid hard waits or hardcoded data. Test code is held to the same standards as production code.
Answer
I create typed client classes per service that wrap HTTP calls, with request and response models, shared auth and logging filters, and tests that use the clients. Schema validation catches contract drift.
java
public class UserClient {
private final RequestSpecification spec;
public UserClient(RequestSpecification spec) { this.spec = spec; }
public Response create(UserRequest body) {
return given(spec).body(body).post("/users");
}
}
Response res = userClient.create(new UserRequest("Asha", "QA"));
res.then().statusCode(201)
.body(matchesJsonSchemaInClasspath("schemas/user.json"));
I create typed client classes per service that wrap HTTP calls, with request and response models, shared auth and logging filters, and tests that use the clients. Schema validation catches contract drift.
Answer
I work with developers to add stable test IDs, test hooks and seed APIs, dependency injection for mocking, feature flags, and good logging. Testable design reduces reliance on brittle UI tests.
Key points
Expose health and version endpoints
Allow time and clock injection
Disable CAPTCHA or OTP in test environments safely
I work with developers to add stable test IDs, test hooks and seed APIs, dependency injection for mocking, feature flags, and good logging. Testable design reduces reliance on brittle UI tests.