SDET Interview Questions and Answers
Last updated 2026-11-19
A software development engineer in test is evaluated as both an engineer and a tester. Expect a coding round close to a developer interview in difficulty, a test design round where you are given a feature and asked to break it, and a framework or architecture discussion. This page has 15 worked questions with code, written in Python and Java: data-structure problems framed around testing, test design exercises, concurrency, mocking, CI and quality strategy.
For tool-specific depth see the Selenium questions, API testing questions and automation testing questions. Coding fundamentals are covered under the Java and DSA hubs, and how to crack a technical interview explains the format.
| Typical loop | Coding round, test design round, framework or system design, behavioural |
|---|---|
| Coding level | Easy to medium DSA, string and collection manipulation, clean readable code |
| Differentiator | Showing how you would test the code you just wrote |
How SDET coding rounds differ
After you solve the problem, interviewers frequently ask: how would you test this? Have a standard answer ready: normal cases, boundaries, empty and null input, large input for performance, invalid input, and concurrency if relevant. Writing two or three unit tests in the same sitting, ideally parametrised, separates SDET candidates from pure developers. State time and space complexity every time.
SDET Interview Questions and Answers: questions with worked answers
1 Write a function to check whether a string is a valid palindrome ignoring case and non-alphanumeric characters, and test it.
easyUse two pointers moving inward, skipping characters that are not alphanumeric and comparing lower-cased characters. It runs in O(n) time and O(1) extra space, better than building a cleaned and reversed copy, which costs O(n) space. Test cases: empty string (true by convention), single character, mixed case with punctuation such as a classic sentence, a non-palindrome, strings of only symbols, and Unicode input if the specification cares.
pythonimport pytest def is_palindrome(s: str) -> bool: i, j = 0, len(s) - 1 while i < j: while i < j and not s[i].isalnum(): i += 1 while i < j and not s[j].isalnum(): j -= 1 if s[i].lower() != s[j].lower(): return False i += 1 j -= 1 return True @pytest.mark.parametrize('s, expected', [ ('', True), ('a', True), ('A man, a plan, a canal: Panama', True), ('race a car', False), ('.,', True), ('ab', False), ]) def test_is_palindrome(s, expected): assert is_palindrome(s) is expected2 Find duplicate elements in an array and state the complexity. How would you test it?
easyUse a hash set: iterate once, and when an element is already in the set, record it as a duplicate. Time is O(n) and space is O(n). If memory is restricted and the array is values from 1 to n, you can mark seen values by negating entries in place, O(1) extra space but mutating the input. Sorting first gives O(n log n) time and O(1) or O(n) space depending on the sort. Tests: no duplicates, all duplicates, a single element, an empty array, negative numbers, and a very large array to check performance.
javaimport java.util.*; public static Set<Integer> findDuplicates(int[] nums) { Set<Integer> seen = new HashSet<>(); Set<Integer> dups = new LinkedHashSet<>(); for (int n : nums) { if (!seen.add(n)) dups.add(n); } return dups; }3 Given a log of timestamps, find the maximum number of concurrent users.
mediumRepresent each session as a start event (+1) and end event (-1), sort the events by time with ends before starts at equal times if sessions touching at a boundary should not overlap, then sweep keeping a running count and its maximum. Complexity is O(n log n) for sorting and O(n) space. A min-heap of end times gives the same bound. Test with no sessions, one session, identical intervals, back-to-back sessions and fully nested intervals.
pythondef max_concurrent(sessions): events = [] for start, end in sessions: events.append((start, 1)) events.append((end, -1)) # -1 sorts before +1 at the same time events.sort() cur = best = 0 for _, delta in events: cur += delta best = max(best, cur) return best assert max_concurrent([]) == 0 assert max_concurrent([(1, 5), (2, 6), (5, 8)]) == 2 assert max_concurrent([(1, 3), (3, 5)]) == 14 Design test cases for a function that validates a password rule: 8 to 20 characters with at least one digit, one uppercase letter and one special character.
mediumApply boundary value analysis on length: 7, 8, 9, 19, 20 and 21 characters while holding other rules satisfied. Apply a one-rule-fails approach: valid length but no digit, no uppercase, no special character, each separately, then all missing. Add equivalence classes: spaces, unicode letters, emoji, leading and trailing whitespace, very long input of thousands of characters, empty and null. Check what counts as special, and that error messages say which rule failed without revealing policy that helps attackers more than users. Automate as a parametrised table.
5 How do you test code with a time dependency or randomness?
mediumInject the dependency instead of calling it directly. Pass in a clock object, a function returning the current time or a seeded random generator, so the test controls the value. In Python, libraries such as freezegun, or unittest.mock to patch the clock, serve the same purpose; in Java, use java.time.Clock with Clock.fixed. For randomness, seed the generator and test properties, such as output within range, rather than specific values. Avoid sleeping in tests: control the clock instead, which makes them fast and deterministic.
pythonfrom datetime import datetime, timedelta def is_expired(created: datetime, now: datetime, ttl=timedelta(hours=1)) -> bool: return now - created >= ttl def test_expiry_boundary(): t0 = datetime(2026, 11, 19, 10, 0, 0) assert not is_expired(t0, t0 + timedelta(minutes=59, seconds=59)) assert is_expired(t0, t0 + timedelta(hours=1))6 Explain mocking with an example, and the risk of over-mocking.
mediumA mock replaces a collaborator, such as a payment gateway or email service, so the unit under test runs quickly and deterministically, and lets you assert that interactions occurred. The example patches an HTTP call and verifies the function handles a failure. The risk is coupling tests to implementation details: if you mock every internal call, refactors break tests even though behaviour is unchanged, and tests can pass while the real integration is broken. Mock at architectural boundaries such as network and clock, prefer fakes for internal collaborators, and keep a few integration tests with the real thing.
pythonfrom unittest.mock import patch import requests def get_rate(cur): try: r = requests.get(f'https://fx.example.test/{cur}', timeout=3) r.raise_for_status() return r.json()['rate'] except requests.RequestException: return None def test_get_rate_handles_outage(): with patch('requests.get', side_effect=requests.ConnectionError): assert get_rate('USD') is None7 Write a thread-safe counter and explain how you would test it for race conditions.
hardAn unsynchronised increment is a read-modify-write, so concurrent threads can lose updates. Protect it with a lock, or use an atomic type such as AtomicInteger in Java. To test, run many threads performing many increments and assert the final total equals threads times increments; run it repeatedly because races are probabilistic. Tools such as ThreadSanitizer, Java's jcstress and stress loops raise the detection chance. Passing a concurrency test does not prove safety, so also review the code for shared mutable state.
javaimport java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; public class CounterTest { public static void main(String[] args) throws Exception { AtomicInteger counter = new AtomicInteger(); int threads = 16, perThread = 100_000; ExecutorService pool = Executors.newFixedThreadPool(threads); CountDownLatch done = new CountDownLatch(threads); for (int t = 0; t < threads; t++) { pool.submit(() -> { for (int i = 0; i < perThread; i++) counter.incrementAndGet(); done.countDown(); }); } done.await(); pool.shutdown(); if (counter.get() != threads * perThread) throw new AssertionError(counter.get()); } }8 How would you test a REST service that sends an email after an order is placed?
mediumTest at several layers. Unit test the order logic with the email sender mocked, asserting it is called once with the right recipient and template. Integration test the service with a fake SMTP server such as MailHog or GreenMail in a container, place an order through the API and query the fake server for the message, asserting subject, recipient and content. Also test failure paths: the mail service down must not fail order creation silently, so verify retry or queueing and that an error is logged. Check idempotency so a retried request does not send two emails, and test that no sensitive data appears in the message.
9 What is the difference between white box coverage metrics, and does 100 percent coverage mean good tests?
mediumStatement coverage measures lines executed; branch coverage measures whether each decision went both ways; condition and path coverage go deeper. Branch coverage is usually the practical minimum. Coverage shows what was executed, not what was verified: a test with no assertions gives coverage but no protection. It also says nothing about missing code for missing requirements. Mutation testing, with tools such as PIT for Java or mutmut for Python, injects small faults and checks that tests fail, measuring the effectiveness of assertions. Use coverage to find untested areas, not as a target to chase.
10 How would you design a framework that tests a microservice system?
hardUse the pyramid: unit tests inside each service, contract tests at each service boundary so providers and consumers can evolve independently, component tests that run one service with its dependencies stubbed, and a thin end-to-end layer for critical flows in an environment with real deployments. Provide shared test tooling: a typed API client, data builders, test containers for databases and queues, and observability hooks that attach trace IDs to failures. Run in CI with parallelism, ephemeral environments per pull request where affordable, and synthetic checks in production after deployment. Manage test data per service and avoid a shared mutable database.
11 A test passes locally but fails in CI. How do you debug?
mediumCompare the environments: OS, browser or runtime versions, timezone and locale, screen resolution and headless mode, available memory and CPU speed, network access, environment variables and the data state. CI machines are slower, exposing missing waits; parallel runs expose shared state. Reproduce locally by running the CI container image, in headless mode, with the same command and ordering, and enable verbose logging, videos and screenshots from CI. Check for reliance on file paths or clock assumptions. Once found, fix the root cause, not by adding a sleep, and add the diagnostic artefact permanently.
12 What is shift-left and shift-right testing?
easyShift-left means testing earlier: reviewing requirements for testability, writing unit and contract tests with the code, static analysis in the editor and pull request, and having testers pair with developers during design, so defects are cheaper to fix. Shift-right means testing in and after production using techniques such as canary releases, feature flags, synthetic monitoring, real-user monitoring, A/B experiments and chaos engineering, because some failures appear only with real traffic and data. Mature teams do both: strong pre-merge checks and strong observability with fast rollback.
13 How do you test a database migration or data pipeline?
mediumVerify schema changes apply cleanly forwards and, where promised, backwards on a copy of production-like data. Compare row counts, checksums or aggregates between source and target, sample rows for field-level equality, and check null handling, encoding, timezone conversion and precision of numerics. Test constraints and indexes, performance against realistic volume, idempotency of reruns, and failure recovery halfway through. Keep the SQL checks as automated tests in the pipeline.
sql-- row counts and a numeric checksum should match between source and target SELECT (SELECT COUNT(*) FROM src.orders) AS src_rows, (SELECT COUNT(*) FROM dst.orders) AS dst_rows, (SELECT SUM(amount) FROM src.orders) AS src_total, (SELECT SUM(amount) FROM dst.orders) AS dst_total; -- rows present in source but missing in target SELECT s.id FROM src.orders s LEFT JOIN dst.orders d ON d.id = s.id WHERE d.id IS NULL;14 Tell me about a time you improved quality, and how you would measure the improvement.
easyChoose a specific story with a problem, an action and a measured result: for example, regression took two days manually and releases slipped, so you automated the top 40 critical paths at API level, cut regression to 25 minutes in CI, and reduced escaped defects in the next quarter. Quote only numbers you genuinely have, and be honest about what did not work. Measures to mention: cycle time, escaped defect rate, flaky test rate, pipeline duration and time to detect. Interviewers value the reasoning and trade-offs more than the size of the number.
Frequently asked questions
What is the difference between a QA engineer and an SDET?
A QA engineer may focus on test design and execution, manual or automated. An SDET is a software engineer who builds test infrastructure, frameworks and tooling, and is usually hired through a coding-heavy interview.
How hard are SDET coding rounds?
Typically easy to medium on arrays, strings, hash maps, sorting and sometimes trees or graphs, with an emphasis on clean code and testing it. Some large companies use the same bar as developers.
Which language should I use for SDET interviews?
Use the language you are strongest in, usually Java or Python, and know its test framework and standard collections. Some roles specify a language, such as C# or JavaScript.
Should I learn system design as an SDET?
At senior levels, yes: you may be asked to design a test platform, a distributed test runner or a testing strategy for a microservice system. Juniors are asked fewer open design questions.
Related guides
- Automation Testing Interview Questions and Answers
- Selenium Interview Questions and Answers
- API Testing and Postman Interview Questions
- Manual Testing Interview Questions and Answers
- Java Interview Questions and Answers
- Performance Testing and JMeter Interview Questions
- DevOps Interview Questions and Answers
More in Role-wise Interview Questions by Job and Tech Stack
- Selenium Interview Questions and Answers
- Site Reliability Engineer (SRE) Interview Questions and Answers
- SOC Analyst Interview Questions and Answers
- Software Engineer Fresher Interview Questions and Answers
- Spring Boot Interview Questions and Answers (Spring Boot 3)
- Statistics for Data Science Interview Questions and Answers
- Tableau Interview Questions and Answers
- Terraform Interview Questions and Answers
- Web Performance Interview Questions and Answers
- Web Security and OWASP Interview Questions and Answers
- A/B Testing Interview Questions and Answers
- Android Developer Interview Questions and Answers