Frameworks and CI · mid
Parallel runs, CI speed and where browsers run
To make a suite fast, measure first, cut setup, and run in parallel safely. A shared static driver breaks parallel runs.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- A static WebDriver field is one field shared by all threads. One thread overwrites it, one tearDown quits the other browser, and you get "invalid session id".
- Fix: ThreadLocal<WebDriver>, set in setup, get through an accessor, and in teardown call quit() then remove(). remove() matters because TestNG reuses pool threads.
- Other shared state that breaks parallel runs: static page objects and static test data.
- synchronized on every method kills the parallelism. volatile does not fix it.
- From two hours to fifteen minutes: measure per-test time and setup time first. Set up through APIs, log in once per worker, remove duplicates, push checks down to API tests.
- Parallel on one machine (workers or threads) and across machines (shards). Playwright: --shard=1/8, the blob reporter and merge-reports. Balance shards by past durations, not by file count.
- Pull request set is a smoke and tagged tests; the full suite runs nightly.
- Browsers: the runner own browser changes when the image updates. Docker with pinned image tags is the same everywhere. Use --shm-size=2g. A cloud grid gives many browsers and real devices but costs per session, is slower per command, and needs a tunnel to reach internal staging.
The red pen
Common traps: mistake → fix
Mistake: Make the field volatile
Fix: the problem is sharing, not visibility.
Mistake: Buy a bigger machine
Fix: measure first; setup is often the cost.
Mistake: Always use the cloud grid, or never
Fix: there are trade-offs in cost, speed, access and data.
Mistake: Use latest tags for browser images
Fix: tests break on someone else schedule.
Easy to hard
Questions interviewers ask, easy to hard
- Tests pass alone but break in a parallel TestNG run with a static driver. Why?
- How do you cut a two-hour suite to fifteen minutes?
- Docker, cloud grid or the runner browser: how do you choose?
- What does remove() do on a ThreadLocal and why call it?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.