QA engineer: Automation and Test Determinism
Original QA interviews on controlled schedules, completion signals, virtual clocks, replayable randomness, fixture ownership, browser races, faithful fakes, and reproducible test execution. Each question states its timing or isolation contract.
These prompts are original practice. They are not questions from a named employer or a live hiring loop.
1.A worker sets ready=true before it begins listening for work. A test waits for ready, sends one task, and sometimes loses it. The fixture may expose one new signal. What should that signal mean?
Show answer and explanation
- The listener is installed and can accept the task
- The previous task's result has been removed
- The worker object has been constructed successfully
- The thread has been created but has not run yet
Answer: The listener is installed and can accept the task
A readiness signal must certify the precondition for the next action. Construction or early startup does not establish that the listener can receive work.
2.A one-shot notification is discarded if no listener exists. A test calls start(), which may finish synchronously and emit Done, then registers its Done listener. How should it order these steps?
Show answer and explanation
- Register the Done listener before calling start()
- Register after start() and increase the wait limit
- Call start() twice and listen only after the second call
- Read the current time before registering after start()
Answer: Register the Done listener before calling start()
Install observation before the action that may emit the event. A larger timeout cannot recover a discarded notification.
3.A callback writes result=7 and then signals Finished. Waiting on Finished establishes visibility of earlier writes. What observation is justified immediately after that wait returns?
Show answer and explanation
- The callback has also completed every later cleanup step
- The callback's executing thread has terminated
- The preceding write of result=7 is visible
- No other thread can subsequently change result
Answer: The preceding write of result=7 is visible
The signal orders preceding writes, not later actions or future mutations. Waiting for one event is not the same as joining the whole worker.
4.Two workers must both read version 0 before either attempts its conditional update. Which test arrangement forces that intended contention point?
Show answer and explanation
- Wait for either worker's update before starting the other
- Pause each worker after its read, then release both
- Start the second worker only after the first update finishes
- Sleep briefly in the test after starting both workers
Answer: Pause each worker after its read, then release both
A barrier placed after both reads forces the stale-version competition. Merely launching workers together does not fix their internal ordering.
5.A retry test must check cancellation while the second attempt is blocked. The fake can pause at request entry and expose an entry signal. Which sequence establishes this case?
Show answer and explanation
- Cancel after the second response arrives
- Cancel before the first attempt starts
- Cancel after an unobserved fixed delay
- Wait for second-entry signal, cancel, then release the fake
Answer: Wait for second-entry signal, cancel, then release the fake
The entry signal proves that the intended attempt is in flight. Cancellation before entry or after completion tests a different state.
6.A test holds mutex M while waiting for worker completion. The worker must acquire M before it can complete. No other action releases M. What does this harness create?
Show answer and explanation
- Evidence that the worker's computation is too slow
- A wait cycle caused by the test's own lock ownership
- Proof that a longer completion timeout will break the cycle
- A valid test of completion while M remains exclusively held
Answer: A wait cycle caused by the test's own lock ownership
The test waits for a worker that waits for the test's mutex. Without releasing that dependency, more time cannot permit completion.
7.A level-triggered event remains set until explicitly cleared. Test A sets it; test B reuses it and waits for a new operation. B's wait returns before that operation starts. What repair targets this failure?
Show answer and explanation
- Reuse it without resetting its flag
- Clear it after the new operation finishes
- Accept its prior set state for every new wait
- Use a fresh event or safely reset it before the new operation
Answer: Use a fresh event or safely reset it before the new operation
A retained signal can satisfy a later wait incorrectly. The next operation needs a clean signaling state before it can emit its own completion.
8.A condition wait may wake without a notification. The protected predicate is queue nonempty. What waiting structure remains correct under that contract?
Show answer and explanation
- Read the predicate once, then trust the first wake
- Treat every wake as proof that one item exists
- Remove the lock because the wait itself checks the queue
- Recheck the predicate in a loop while holding its lock
Answer: Recheck the predicate in a loop while holding its lock
The predicate determines readiness; a wake only prompts another check. The lock protects that check against concurrent state changes.
9.A test must observe that a callback has not occurred before a deadline. A fake scheduler can enumerate every callback due through time 20. Which check actually exercises that interval?
Show answer and explanation
- Inspect only callback registration success
- Run all due callbacks through 20, then inspect the callback log
- Advance time without executing callbacks
- Inspect the log before driving due work
Answer: Run all due callbacks through 20, then inspect the callback log
A negative temporal assertion needs the relevant interval to be executed or ruled out. An immediate empty log says nothing about later due work.
10.A future's await operation rethrows a worker exception. A test submits work but never awaits the future; its last assertion passes. What harness change ensures the worker failure affects the test?
Show answer and explanation
- Await the owned future before declaring test success
- Catch every worker exception and return a default value
- Print the future's identifier after submission
- Discard the future after asserting submission succeeded
Answer: Await the owned future before declaring test success
Submission success is distinct from completion success. Awaiting the owned result joins the failure into the test's control flow.
11.A queue's
task_done() means processing has ended. A worker calls it immediately on dequeue, then performs the write. A test joins the queue and checks storage. Why can that check race?Show answer and explanation
- Dequeue makes the later write atomic
- Queue join waits for the whole worker thread
- The join tracks the early acknowledgment, not the later write
- The database must have discarded a completed write
Answer: The join tracks the early acknowledgment, not the later write
The harness must align acknowledgment with the completion boundary it needs. An early acknowledgment can make join return while processing continues.
12.A test waits until the global completed-job count rises from 40 to 41. Unrelated jobs may finish concurrently. Which observation binds readiness to the test's own work?
Show answer and explanation
- The total count reaching the next multiple of ten
- Any global count increase larger than zero
- Completion carrying the submitted job's correlation ID
- A process-wide log message saying that a worker is active
Answer: Completion carrying the submitted job's correlation ID
A global increment can come from another job. Correlation connects the observed completion to the specific submitted operation.
13.A fake executor stores submitted tasks without running them. A method submits one task and returns a handle. Immediately after the method returns, no task has been drained. What is valid to assert?
Show answer and explanation
- The production executor must also defer every task forever
- The task's future has failed because storage is unchanged
- The submitted task has completed because submission returned
- One task was queued, without assuming its effects occurred
Answer: One task was queued, without assuming its effects occurred
This fake separates submission from execution deliberately. Drive the stored task before asserting its downstream effects.
14.A callback registry invokes every registered listener once per event. A fixture registers the same test handler twice and emits one event. The count becomes 2. What should be corrected first?
Show answer and explanation
- The assertion to accept any positive callback count
- The event payload so duplicate listeners receive different data
- The fixture's duplicate subscription and teardown bookkeeping
- The production event count, which must have been two
Answer: The fixture's duplicate subscription and teardown bookkeeping
Two subscriptions explain two calls under the stated contract. Fix the duplicated observation before attributing the count to duplicate production emission.
15.A manual scheduler requires every child task to finish before a parent handle is complete. Parent P starts child C and returns. C remains queued. Which state should this scheduler report for P?
Show answer and explanation
- Complete as soon as P's function returns
- Pending completion until C finishes
- Cancelled because the parent owns child C
- Failed merely because C was queued
Answer: Pending completion until C finishes
The supplied completion contract includes child work. Function return alone is insufficient to mark the parent handle complete.
16.A delayed callback from attempt 1 may arrive after attempt 2 starts. A test reuses one untagged completion channel and accepts the first message. What change prevents a stale response from satisfying attempt 2?
Show answer and explanation
- Choose the response with the lowest timestamp
- Match completion to the current attempt's generation token
- Accept any message arriving after attempt 2 starts
- Drain old messages only before starting attempt 2
Answer: Match completion to the current attempt's generation token
A generation token distinguishes callbacks from separate attempts even when arrival order differs from start order.
17.A deterministic scheduler explores executions of A1 before A2 and B1 before B2, with no other ordering constraints. How many complete interleavings preserve those per-worker orders?
Show answer and explanation
- 6
- 24
- 4
- 8
Answer: 6
Choose the two positions occupied by A's steps among four: C(4,2)=6. Treating all four steps as freely permutable would violate the worker orders.
18.Two workers each read shared x, then write their read value plus 1. Initially x=0. The scheduled order is readA,readB,writeA,writeB. What final value should the harness observe?
Show answer and explanation
- 0
- 1
- 2
- 4
Answer: 1
Both reads obtain 0 and both writes store 1. The explicit schedule exposes a lost update without depending on timing luck.
19.A test blocks network replies until Release is signaled. It waits for a successful reply before signaling Release. No other actor can signal it. Which dependency must be changed?
Show answer and explanation
- The response assertion must demand a larger payload
- The request must remain blocked until its own success arrives
- The listener must ignore all Release notifications
- Release must be driven independently of the blocked reply
Answer: Release must be driven independently of the blocked reply
The test made release depend on the result that release enables. Drive the control signal from a reachable test action.
20.A test's controlled scheduler governs task dispatch, but the program reads an uncontrolled external message stream. Identical task schedules yield different results. What else must replay capture or control?
Show answer and explanation
- Only the count of worker threads in the pool
- Nothing, because dispatch determinism guarantees input determinism
- The relevant external message sequence and contents
- Only the final callback's displayed timestamp
Answer: The relevant external message sequence and contents
A fixed schedule does not fix external inputs. Reproducing the execution requires the input events that influence it as well.
21.A duration check starts with wall time 100 and ends at wall time 95 after a clock correction. What measurement should this elapsed-time test use instead?
Show answer and explanation
- The absolute difference between the two wall readings
- A monotonic clock difference within one clock domain
- The larger of the two wall timestamps
- The wall timestamp converted to a different time zone
Answer: A monotonic clock difference within one clock domain
Wall time can jump; monotonic differences measure elapsed intervals without that discontinuity. Taking an absolute value merely hides the clock error.
22.A fake clock starts at 0. Timers A and B are due at 5 and 8. Advancing to 6 executes every due timer exactly once. Which callback log is expected?
Show answer and explanation
- [B]
- []
- [A,B]
- [A]
Answer: [A]
Only A's deadline is at or before 6. B remains scheduled until the fake reaches at least 8.
23.A virtual scheduler runs due callbacks in deadline order. Callback A at t=4 schedules B with delay 2 relative to its execution time. Advancing from 0 through 10 drains all due work. When does B run?
Show answer and explanation
- At virtual time 2
- At virtual time 6
- Only on a second advance after time 10
- At virtual time 10
Answer: At virtual time 6
A executes at its own deadline 4; adding delay 2 gives 6. The advance drains newly scheduled work that is also due by 10.
24.Two timers share deadline 7. Their scheduler's contract leaves tie order unspecified. The test concerns only eventual execution of both. Which assertion respects that contract?
Show answer and explanation
- Require A before B based on lexical order
- Both IDs appear once, without fixing their relative order
- Allow either ID to occur twice instead
- Require insertion order despite no tie rule
Answer: Both IDs appear once, without fixing their relative order
Unspecified tie order permits either ordering. Assert the guaranteed membership and multiplicity rather than inventing an ordering promise.
25.A debounce rule emits the latest input after 5 units without a newer input. Inputs arrive at t=0 with A and t=3 with B. No others arrive. What emission should a virtual-time test expect?
Show answer and explanation
- A and B together at t=3
- B at t=5 only
- A at t=5 and B at t=8
- B at t=8 only
Answer: B at t=8 only
B replaces A's pending emission and restarts the five-unit quiet interval. The next deadline is 3+5=8.
26.A retry policy waits 2, then 4, then 8 time units after successive failures. The first attempt fails at t=0; every later failed attempt completes instantly. When does attempt 4 start?
Show answer and explanation
- t=14
- t=8
- t=16
- t=12
Answer: t=14
Attempt 2 starts at 2, attempt 3 at 2+4=6, and attempt 4 at 6+8=14. The waits are cumulative, not absolute deadlines.
27.A fake clock intercepts now(), but the timeout implementation still uses the real operating-system timer. Advancing fake time by an hour does not fire the timeout. What seam is incomplete?
Show answer and explanation
- The timeout needs more timestamp precision
- The timer scheduling mechanism is outside the fake's control
- The real timer needs a different time zone
- The fake timestamp must be read twice
Answer: The timer scheduling mechanism is outside the fake's control
Controlling timestamp reads alone does not control timer execution. The scheduler and the clock must agree for deterministic virtual-time behavior.
28.A token is valid exactly when now<expiry. Expiry is 40. A fake supplies times 39,40,41 on three separate checks. Which validity sequence is required?
Show answer and explanation
- Invalid, invalid, valid
- Invalid, valid, valid
- Valid, invalid, invalid
- Valid, valid, invalid
Answer: Valid, invalid, invalid
The strict inequality excludes the boundary itself. At now=40, now<40 is false.
29.A UI clock is frozen at t=0 and animations run only when that clock advances. A browser click helper waits until a moving button becomes stable. What can unblock the test while preserving the intended animation case?
Show answer and explanation
- Read the final CSS without driving its frames
- Wait longer while virtual time remains frozen
- Bypass stability and claim animation completion
- Advance the controlled animation clock until motion completes
Answer: Advance the controlled animation clock until motion completes
Real waiting cannot finish an animation driven only by frozen virtual time. Drive the controlled frames before expecting stability.
30.A local calendar contract uses a fixed UTC+03:00 offset, with no seasonal changes. At 22:30 UTC on May 10, what date should the local-date fixture expect?
Show answer and explanation
- May 11
- The date cannot be derived from the supplied offset
- May 10
- May 9
Answer: May 11
Adding three hours yields 01:30 on the next day. Fixing the offset makes this a deterministic calendar case.
31.A timeout is recorded as monotonic timestamp 120 on host A. Host B's monotonic clock has an unrelated origin. What should an automation harness avoid?
Show answer and explanation
- Comparing B's raw monotonic reading directly with A's deadline
- Recording host and clock-domain identity
- Taking two compatible readings locally on A
- Storing a timeout duration in common units
Answer: Comparing B's raw monotonic reading directly with A's deadline
Monotonic readings support differences within a compatible clock domain. Unrelated origins do not provide a cross-host absolute deadline comparison.
32.A periodic timer fires every 3 units from t=0. The fake explicitly runs every missed tick when advanced, with no coalescing. Advancing to t=10 should produce how many firings?
Show answer and explanation
- 10
- 4
- 1
- 3
Answer: 3
The deadlines are 3,6,9 before time 10. The stated policy neither collapses them into one firing nor adds an initial firing at zero.
33.A test freezes wall time before calling code that measures a real timeout with monotonic time. Is that alone enough to make timeout completion instantaneous and deterministic?
Show answer and explanation
- Yes; every clock override replaces all timers
- No; the elapsed-time source and waiting mechanism remain uncontrolled
- No; timeouts cannot be tested with virtual time
- Yes; a frozen wall clock fires pending timers
Answer: No; the elapsed-time source and waiting mechanism remain uncontrolled
The program's actual timing dependencies matter. A wall-clock override does not automatically replace monotonic waits or their scheduler.
34.A pseudo-random generator is specified by
x_next=(5x+1) mod 8, returning each new state. With seed 2, what first three values should a replay fixture expect?Show answer and explanation
- 2,3,0
- 3,0,1
- 0,1,6
- 3,1,6
Answer: 3,0,1
The transitions are (5×2+1) mod8=3, then16 mod8=0, then1. The seed is the initial state, not the first returned value.
35.Workers A and B share one seeded generator. The scheduler determines which worker receives each next value. Same seed, different schedules, different worker inputs: what provides schedule-independent input assignment?
Show answer and explanation
- Separate stable per-worker random streams or recorded inputs
- Sort outputs after workers consume inputs
- Reset the shared seed once per suite
- Record only the common stream seed
Answer: Separate stable per-worker random streams or recorded inputs
The seed fixes the shared sequence, but scheduling assigns its elements. Independent streams or explicit input recording remove that assignment ambiguity.
36.A failure receipt stores a seed but not the generator algorithm or the input-generator version. Both changed before replay. What additional evidence is needed for reliable reconstruction?
Show answer and explanation
- Only the runtime version and test name
- Only the seed and original output count
- The generator identity/version and relevant input-generation code revision
- Only the failed assertion and its duration
Answer: The generator identity/version and relevant input-generation code revision
A seed has meaning within a particular generation process. Algorithm or generator-code changes can map it to a different case.
37.A deterministic shuffle depends on the initial list order as well as a seed. The fixture reads files in an unspecified directory enumeration order. What must it stabilize before shuffling?
Show answer and explanation
- Only the file count before shuffling
- The input enumeration order, such as by explicit sorting
- Only the seed, leaving enumeration unspecified
- Only the output permutation length
Answer: The input enumeration order, such as by explicit sorting
The same random choices applied to different initial lists can yield different permutations. Canonicalize the input order or record it.
38.A synthetic ID provider returns successive values K1,K2,K3. A helper consumes one ID before the operation under test, which then consumes two. What IDs should this fixture expect from that operation?
Show answer and explanation
- K2 and K3
- K3 and K3
- K1 and K3
- K1 and K2
Answer: K2 and K3
The provider is stateful. The helper has already consumed K1, so the operation receives the next two values.
39.A deterministic test injects a fake random provider into service S. A private dependency creates its own production random provider. What does the harness need to control to reproduce S's behavior?
Show answer and explanation
- Only the random provider injected into S
- Only the first generated random value
- Only the dependency’s random-call count
- The dependency's relevant random source as well
Answer: The dependency's relevant random source as well
Injection at one layer does not control a separate source created below it. Replay must cover every randomness dependency that influences the tested behavior.
40.A failure depends on a sequence of generated commands and their scheduler choices. The same input seed reproduces the commands but not their interleaving. What replay record closes that gap?
Show answer and explanation
- Only the generated command count
- Only the input seed without scheduler decisions
- The relevant schedule decisions alongside the generated commands
- Only the final shared state
Answer: The relevant schedule decisions alongside the generated commands
Replaying input generation and replaying execution order are separate requirements. Preserve or control the schedule that triggers the failure.
41.Fixture setup creates directory D successfully, then creating database B fails. Cleanup is written only after a later 'setup complete' yield that is never reached. What structure protects D on this failure path?
Show answer and explanation
- Register D's cleanup immediately after its successful creation
- Register all cleanup after setup completes
- Retry B without tracking the existing D
- Assume setup failure deletes acquired resources
Answer: Register D's cleanup immediately after its successful creation
Cleanup ownership should be established as each resource is acquired. A later setup failure must not bypass cleanup for earlier successful steps.
42.Resource B depends on A; resource C depends on B. They were acquired A,B,C. Cleanup must keep each dependency alive until its dependent is removed. Which teardown order works?
Show answer and explanation
- B,A,C
- A,B,C
- C,B,A
- B,C,A
Answer: C,B,A
Release dependents before their dependencies. Reversing the acquisition chain preserves each prerequisite until it is no longer needed.
43.A fixture's database delete fails. Its cleanup code then exits before closing an independent owned socket. What teardown policy prevents that socket leak?
Show answer and explanation
- Hide the database error and report the test as successful
- Attempt both cleanups and report the collected failures
- Retry the entire test body before attempting socket cleanup
- Skip socket cleanup whenever database cleanup fails
Answer: Attempt both cleanups and report the collected failures
Independent owned resources still need cleanup after one cleanup fails. Preserve the errors while attempting every applicable release.
44.A pool has two connections. An outer test transaction holds one. Two concurrent workers each need one connection and must both reach a barrier before either releases it. What harness resource issue occurs?
Show answer and explanation
- The barrier automatically increases pool capacity to three
- Both workers can reach the barrier using the single free connection
- Only one worker can acquire a connection, blocking the barrier
- The outer transaction releases its connection when a worker waits
Answer: Only one worker can acquire a connection, blocking the barrier
The outer holder leaves one slot for two workers that must hold slots concurrently. The harness cannot reach the intended synchronization point with that allocation.
45.A test rolls back its own database transaction, but the service under test commits on a different connection outside it. What isolation claim is unsupported?
Show answer and explanation
- That committed service rows require their own cleanup strategy
- That the test can roll back writes inside its own transaction
- That the test's rollback removes the service's committed rows
- That separate connections may have separate transaction scopes
Answer: That the test's rollback removes the service's committed rows
A rollback applies to its transaction, not unrelated committed work. Isolation must account for the service's actual connection and transaction boundary.
46.A process-wide environment variable is read at module import and cached. A test changes the variable after importing the module. Why does behavior retain the old setting?
Show answer and explanation
- The test should wait until the operating system propagates the value to the cache
- The module must read the parent process environment on every function invocation
- The changed variable is guaranteed to replace every previously cached copy
- The tested configuration was already captured at import
Answer: The tested configuration was already captured at import
The setup changed a source after the program had copied it. Import after configuration setup, isolate the module, or use an explicit configuration seam.
47.A fixture restores CONFIG to a hard-coded default after each test. The process had a legitimate nondefault CONFIG before the fixture ran. What should restoration use?
Show answer and explanation
- The value left by the most recent test's assertions
- Always an empty string regardless of prior state
- Always the default from the current source file
- The exact value or absence captured before mutation
Answer: The exact value or absence captured before mutation
Restoration must return the environment to its actual prior state, including the distinction between absence and a present value.
48.Two parallel tests each save a process-global locale, change it, then restore it. Their critical intervals overlap. Why is save-and-restore insufficient here?
Show answer and explanation
- Restoration makes all intermediate observations independent
- The locale affects only log messages, never the tested code
- Saving a locale automatically locks all locale-dependent calls
- Each test can observe or restore the other's temporary locale
Answer: Each test can observe or restore the other's temporary locale
Restoration addresses eventual state, not overlapping access. Serialize this shared dependency or isolate it into separate processes or explicit per-call configuration.
49.A parent test launches a child process that reads an environment variable only at startup. The parent changes its own copy afterward. What should a deterministic fixture do?
Show answer and explanation
- Restore the parent variable and assume the child restarts with that restored value
- Change the parent environment after spawn and assume the child shares its live map
- Send a normal request and assume it refreshes startup-only configuration automatically
- Pass the intended environment when starting the child
Answer: Pass the intended environment when starting the child
The child's startup configuration is a separate captured environment. Set it explicitly at process creation rather than relying on later parent mutations.
50.A server fixture probes a free TCP port, closes the probe, then starts its server on that port. Another process may bind between those steps. What removes this allocation race?
Show answer and explanation
- Choose one fixed high-numbered port and assume other test runs cannot use it
- Probe the port immediately before startup and assume availability reserves it
- Close the probe, wait briefly, then assume the allocation window has become safe
- Let the server bind port 0 and report its actual assigned port
Answer: Let the server bind port 0 and report its actual assigned port
Binding port 0 allocates an available port as part of the server's own bind. A separate availability probe does not reserve its result.
51.A temporary directory path contains only worker number 2. Two separate suite runs each have worker 2 and overlap on one machine. Which scope should its ownership key include?
Show answer and explanation
- A unique run ID as well as the worker and resource identity
- Only a test name, even when the same test can run concurrently in separate invocations
- Only a worker ID, assuming that worker numbering is globally unique across runs
- Only the shared repository name, assuming concurrent runs cannot use the same checkout
Answer: A unique run ID as well as the worker and resource identity
Worker numbers are usually unique only within one run. Concurrent runs need separate namespaces too.
52.A test deletes every object whose name starts with 'test-'. Other concurrent runs use that prefix too. What cleanup rule confines deletion to the fixture's ownership?
Show answer and explanation
- Delete everything created after this run began, including concurrent runs’ objects
- Delete all matching test prefixes because a shared naming convention proves ownership
- Delete only exact resource IDs recorded by this run
- Delete every resource in the shared namespace, then recreate the expected fixtures
Answer: Delete only exact resource IDs recorded by this run
An exact ownership ledger separates this fixture's resources from others. A broad prefix is not proof that a particular run owns an object.
53.A worker thread can still access fixture files after cancellation is requested. The cancellation call does not wait for termination. What should teardown do before deleting those files?
Show answer and explanation
- Join the worker's termination, with a bounded failure path
- Assume cancellation means every pending file access has ended
- Delete the files immediately after requesting cancellation
- Mark cleanup successful if the cancellation flag was set
Answer: Join the worker's termination, with a bounded failure path
A request to stop is not evidence of termination. Join owned work before releasing resources it may still use.
54.A fixture owns a server process and its listening socket. A readiness check times out, but the process is still alive. What is the correct teardown action?
Show answer and explanation
- Start another server and forget the original process handle
- Stop and reap the owned process despite readiness failure
- Treat the timeout as proof the server process has exited
- Skip teardown because startup never became ready
Answer: Stop and reap the owned process despite readiness failure
Readiness and liveness are separate states. Failed startup still requires cleanup of any resource actually acquired.
55.A fixture reuses a cached object whose nested list is mutable. It shallow-copies the object for each test. One test appends to the nested list. What isolation defect remains?
Show answer and explanation
- Appending replaces only the local list variable and cannot mutate the shared list object
- Restoring the outer reference necessarily reverses all mutations made through the list
- A shallow copy recursively duplicates the nested list as well as the outer object
- The nested list is still shared between those copies
Answer: The nested list is still shared between those copies
A shallow copy duplicates the container while retaining references to nested objects. Construct fresh nested state or copy at the required depth.
56.A test controls application storage but leaves the browser's service-worker cache from a previous run. The page can serve old scripts without a network fetch. What boundary needs isolation too?
Show answer and explanation
- Only HTTP cookies, assuming cookie reset also deletes every service-worker cache
- Only server storage, because a cleared server database invalidates all browser caches
- Only page navigation, assuming each navigation must fetch every script from the server
- The service worker and its relevant cache state
Answer: The service worker and its relevant cache state
Server-side reset does not remove browser-managed cache state. The fixture must establish the client state relevant to the requested version.
57.A test uses unique resource names, but every request consumes the same shared API quota. Parallel tests exhaust it. What does unique naming fail to isolate?
Show answer and explanation
- Unique names guarantee independent quotas whenever resource identities differ
- A larger random suffix changes how much shared quota each identical request consumes
- The shared capacity budget used by all those resources
- Deleting the local fixture ledger releases all provider quota immediately
Answer: The shared capacity budget used by all those resources
Names isolate identity, not every underlying dependency. A shared rate or capacity budget still couples parallel tests.
58.A fake filesystem uses case-sensitive names; the supported deployment filesystem is explicitly case-insensitive. A case-variant overwrite passes only on the fake. What test change addresses this semantic gap?
Show answer and explanation
- Exercise that rule against matching filesystem semantics
- Assert only write-call counts and infer that overwrite semantics match the deployment
- Avoid case-variant names and claim that the supported filesystem behavior was tested
- Add more letter-case examples while continuing to use the same case-sensitive fake
Answer: Exercise that rule against matching filesystem semantics
A fake must match the behavior relevant to the test claim. This case needs case-insensitive semantics rather than more cases under the wrong model.
59.An integration fixture starts a writer at revision 12, but its search replica has applied only revision 10. The test needs read-your-write evidence for a new record at revision 13. What readiness check matches the need?
Show answer and explanation
- Wait for that replica to apply at least revision 13
- Check that the search process has a positive uptime
- Wait until the writer's TCP port accepts a connection
- Read any older record successfully from the replica
Answer: Wait for that replica to apply at least revision 13
Process health does not establish data readiness. The replica watermark must cover the specific write being checked.
60.A database test depends on a background index build. The fixture waits only for the database process to start. What should it establish before checking index-dependent behavior?
Show answer and explanation
- That the required index build has completed successfully
- That a general ping succeeds, even while the required index is still building
- That a fixed startup delay elapsed, without observing index completion or failure
- That a connection pool was created, without executing an index-readiness check
Answer: That the required index build has completed successfully
Startup readiness is weaker than feature readiness. Observe the actual prerequisite rather than substituting a fixed delay or unrelated health check.
61.A page replaces a row node after editing its label. A test saves a raw handle to the old node, then clicks it after replacement. What improves the automation boundary?
Show answer and explanation
- Disable the application's replacement behavior in every test
- Find the row only by its previous position in the list
- Resolve the intended current row again using stable identity
- Keep clicking the disconnected handle until timeout
Answer: Resolve the intended current row again using stable identity
A stale node handle describes a former element. Re-resolve the current target using an identity that survives the intended rerender.
62.Two dialogs each contain a Save button. A test intends to save the dialog labeled 'Sensor settings'. Which locator scope best states that target?
Show answer and explanation
- A Save button selected by document order rather than the intended dialog identity
- The first globally matched Save button, even when both dialogs are present
- Save within the Sensor settings dialog
- All Save buttons together, treating either dialog’s successful save as the intended one
Answer: Save within the Sensor settings dialog
Meaningful container scope disambiguates identical action labels. Global order or geometry does not identify the intended dialog.
63.A list may be sorted differently while each row retains a unique item ID. The test must delete item K. What selection remains tied to the intended action?
Show answer and explanation
- A delete control chosen by current screen position without inspecting the row ID
- The first delete control found after a page refresh, regardless of the item it owns
- The delete control within the row identified as K
- The delete control in the third row, assuming sorting cannot change identity there
Answer: The delete control within the row identified as K
Stable row identity preserves intent when order changes. Positional selection can delete another item without a locator failure.
64.A click helper confirms a button is visible, stable, enabled and unobscured. Clicking starts an asynchronous export. What additional observation is needed before asserting exported file contents?
Show answer and explanation
- Only the button's unchanged accessible name
- Only another successful actionability check on the button
- Completion of the specific export and its resulting file
- Only the click helper's own successful return
Answer: Completion of the specific export and its resulting file
Actionability establishes that the action can be performed. It does not certify completion of the business operation started by that action.
65.A test disables a browser click's hit-target checks because an overlay intercepts it. The intended user workflow requires the overlay to close first. What should the test drive or observe?
Show answer and explanation
- The overlay's intended dismissal before a normal click
- The target's source-code existence while leaving the overlay open
- A forced click through the overlay as the only user-path evidence
- A successful DOM method call on the hidden target as proof of access
Answer: The overlay's intended dismissal before a normal click
Drive the actual interaction precondition. Bypassing interception can hide a workflow defect instead of proving a user can perform the action.
66.A download writes bytes to a temporary file before signaling successful completion. File existence can be observed during the write. What must the test await before asserting final file bytes?
Show answer and explanation
- The identified download’s successful completion, then read its final artifact
- Only a stable file size over one short interval, despite possible pauses during transfer
- Only the button click’s return, even though the transfer is still in progress
- Only temporary-file creation, treating existence as evidence that all bytes were written
Answer: The identified download’s successful completion, then read its final artifact
File existence and a brief pause do not establish transfer completion. Use the download’s completion boundary and inspect the resulting final artifact.
67.Submitting order K starts requests for K and unrelated telemetry. A test waits for the first response whose URL contains '/api/'. What should its response predicate identify?
Show answer and explanation
- The first API response on the same host, without checking which request it answers
- Any successful API response after the click, including unrelated telemetry
- Any response body containing an order-shaped object, regardless of the requested ID
- The intended operation, request identity and relevant response
Answer: The intended operation, request identity and relevant response
A broad match can be satisfied by telemetry. Bind the wait to the operation whose completion supports the assertion.
68.A page keeps a heartbeat connection open permanently. An automation step waits for zero active network connections before checking a completed search. What wait target better matches the workflow?
Show answer and explanation
- Increase the same global-idleness timeout without changing its completion condition
- Wait for every connection to close, even though the heartbeat intentionally persists
- Treat connection creation as search completion without observing a search response
- The requested search result's ready state or identified response
Answer: The requested search result's ready state or identified response
An intentional persistent connection can make global idleness impossible. Observe the specific search completion rather than unrelated background activity.
69.A test types a filter that updates results after a debounce delay. It immediately reads the current rows, which still represent the previous query. What should its eventual assertion bind to?
Show answer and explanation
- The first response after typing, regardless of whether it belongs to an earlier query
- The new input value alone, without checking which query produced the displayed rows
- The result state corresponding to the newly entered query
- Any existing nonempty list, even if it is still labeled with the previous query
Answer: The result state corresponding to the newly entered query
Existing rows can satisfy a weak readiness check. The assertion must distinguish the new query's completed state from stale results.
70.A browser test mocks a response only after navigation. The page may fetch during initial rendering and finish before the mock is installed. How should setup order change?
Show answer and explanation
- Navigate again without ensuring the handler exists before either fetch can begin
- Install the handler after rendering and assume it changes the already received body
- Wait longer after navigation and infer that a completed fetch used the later mock
- Install the route handler before navigation can trigger the fetch
Answer: Install the route handler before navigation can trigger the fetch
A mock must intercept the request at the time it is issued. Installing it afterward cannot retroactively control a completed fetch.
71.A route rule is deliberately specified to match every URL containing '/items'. A later, more specific rule should handle '/items/42', but the fake always uses its first matching rule. How should the fixture remove this shadowing?
Show answer and explanation
- Give the specific rule precedence or narrow the broad rule
- Change only the expected body while leaving dispatch unchanged
- Retry the same request until a different rule is selected
- Add more broad '/items' rules ahead of the specific rule
Answer: Give the specific rule precedence or narrow the broad rule
Under first-match dispatch, an earlier broad rule captures the specific route. Fix precedence or matching rather than assuming a later handler runs.
72.A response stub always returns its body immediately. The UI must show Loading while a request is pending. What fake capability makes that state deterministically testable?
Show answer and explanation
- A response gate that the test releases after checking Loading
- A shorter response body while keeping the response fully synchronous
- A delayed assertion without holding the response at any controlled pending boundary
- An immediate response and an assertion made only after the response has completed
Answer: A response gate that the test releases after checking Loading
Hold the response at a controlled boundary so the intermediate state persists long enough to assert, then release and check completion.
73.A contract test checks request method and body, but its fake accepts every authorization header. The test claims to prove correct token forwarding. Which assertion is missing?
Show answer and explanation
- A body-field count, assuming matching body shape proves authorization forwarding
- A check that the response was successful, even if the fake ignores token contents
- A second method assertion, assuming it also verifies every request header
- Validation of the actual forwarded authorization value
Answer: Validation of the actual forwarded authorization value
An accepting fake cannot establish a property it never inspects. Assert the relevant header at the request boundary.
74.A byte-stream parser must handle a record split across chunks. The fake supplies only one complete record per chunk. Which input best exercises the missing boundary?
Show answer and explanation
- Two separate deliveries each containing one complete record, with no split record
- Only empty chunks before a complete record, without splitting meaningful bytes
- Chunks that split one record's bytes across separate deliveries
- Several intact records in one chunk, keeping every record boundary aligned
Answer: Chunks that split one record's bytes across separate deliveries
Chunk boundaries need not align with logical records. A split delivery tests buffering and reassembly rather than only whole-record parsing.
75.A socket fake invokes callbacks inline. The real adapter promises to invoke them only after the current call returns. What should a faithful automation fake preserve?
Show answer and explanation
- Inline callbacks for convenience, while claiming the real deferred ordering was exercised
- A random callback time on every invocation, even though the adapter promises deferral
- The deferred callback boundary when that ordering affects behavior
- Only the response payload, assuming inline and deferred callbacks are interchangeable
Answer: The deferred callback boundary when that ordering affects behavior
Callback timing is part of the stated adapter semantics. An inline fake can create or hide reentrancy behavior absent from the real boundary.
76.Concurrent reads of independent keys P and Q may occur in either order. A strict mock expects P then Q and fails on Q then P, though both responses are correct. What mock behavior matches the supplied contract?
Show answer and explanation
- Respond by request key without imposing a total call order
- A failure whenever Q arrives first, treating a legal schedule as an implementation error
- One shared response for both keys without validating which key was requested
- A fixed total P-then-Q call order, even though the reads are contractually independent
Answer: Respond by request key without imposing a total call order
The contract permits either ordering of independent reads. Key-based dispatch checks the relevant behavior without inventing a sequencing requirement.
77.A fake transport exposes SendAccepted and PeerReceived as different events. The test claims to prove delivery after observing only SendAccepted. What event would support that stronger claim?
Show answer and explanation
- An empty local send buffer without peer evidence
- SendAccepted for a different message from the same process
- The transport object's successful construction
- PeerReceived for the specific sent message
Answer: PeerReceived for the specific sent message
Local acceptance is a different boundary from remote receipt. Observe the peer's identified receipt when delivery is the property being asserted.
78.A scripted fake returns Error then Success across two calls. A test reruns using the same exhausted fake instance. What must retry setup establish to replay the original case?
Show answer and explanation
- Only reset assertion-local variables
- The exhausted script state, treating the rerun as a continuation of the first attempt
- A fresh script cursor and matching initial fake state
- Only the test’s assertion variables, leaving the scripted fake’s consumed responses unchanged
Answer: A fresh script cursor and matching initial fake state
A scripted fake has execution state. Repeating the case requires restoring its initial cursor and other relevant state, not merely repeating the test function.
79.A recorded request contains a temporary host name. The replay matcher ignores the entire URL to avoid host differences, but /read and /delete must remain distinct. What normalization preserves that distinction?
Show answer and explanation
- Replay the next recorded response regardless of which operation the request invokes
- Normalize the host while retaining the meaningful method and path
- Match only the request body, ignoring a meaningful method and route distinction
- Discard both host and path
Answer: Normalize the host while retaining the meaningful method and path
Normalize the declared variable component, not semantically meaningful route information. Overbroad matching can replay a read response for a delete request.
80.A test records data fetched from a service but omits its initial revision. Replaying commands against a later dataset gives different results. What receipt would make the starting state reconstructable?
Show answer and explanation
- Only the final response, without preserving the state before the command sequence
- The latest available dataset, assuming identical commands require no initial-state match
- Only the current dataset URL
- The exact initial snapshot or immutable reference to its revision
Answer: The exact initial snapshot or immutable reference to its revision
Inputs include the state the commands operate on. A later mutable dataset is not necessarily the state that produced the failure.
81.A test depends on a package resolved through an unpinned 'latest' label. Source code and test inputs are unchanged, but a dependency update changes behavior. What should a reproducibility receipt identify?
Show answer and explanation
- Only direct package names and counts, omitting versions and transitive resolution
- The exact resolved dependency graph or immutable artifact digest
- Only the mutable package label
- Only the source commit, even though the dependency can change independently of it
Answer: The exact resolved dependency graph or immutable artifact digest
An unpinned label can resolve differently over time. Record the actual artifact or full resolution that executed the test.
82.A build cache key includes source files but omits the code generator's version. Two versions produce different generated parsers from the same input. What belongs in this cache identity?
Show answer and explanation
- Only the application commit, while resolving the generator from a mutable external label
- Only the schema input bytes
- The generator version and other output-affecting inputs
- Only the generated file’s pathname, even when two generators emit different bytes there
Answer: The generator version and other output-affecting inputs
Cache equivalence must account for inputs that determine the artifact. Omitting a changing generator can return an artifact built under different semantics.
83.A golden-file test writes expected bytes through platform-default newline conversion. The contract requires literal LF bytes on every platform. What should the fixture use?
Show answer and explanation
- A comparison that removes all newlines, hiding differences the byte contract distinguishes
- The host’s default newline conversion
- An explicit byte-level LF representation for the expected file
- A line-count check that ignores whether the required LF bytes are actually present
Answer: An explicit byte-level LF representation for the expected file
The expectation must express the portable byte contract. Host-default text conversion changes that expectation before comparison.
84.A parser test's fixture path is relative to the process working directory. Running from another directory opens a different file with the same name. What makes fixture selection stable?
Show answer and explanation
- The most recently modified matching file, treating recency as the required fixture identity
- Resolve the intended fixture from an explicit anchored location
- The current working directory
- The first machine-wide basename match, without validating which fixture was selected
Answer: Resolve the intended fixture from an explicit anchored location
An explicit anchor removes dependence on an ambient working directory. Filename coincidence is not stable fixture identity.
85.A harness treats object-key enumeration order as input to a deterministic scheduling algorithm. Its input source explicitly leaves that order unspecified. What must the fixture record or define?
Show answer and explanation
- Only the scheduler seed, leaving its order-sensitive input enumeration uncontrolled
- Only the final output length, without recording the key order that influenced scheduling
- Only the unordered key set
- A canonical key order or the exact order used in the failed run
Answer: A canonical key order or the exact order used in the failed run
The algorithm is deterministic only for a fixed ordered input. Unspecified enumeration remains an uncontrolled dependency.
86.Test T passes alone but fails only after A then B. A binary reducer checks halves [A] and [B] separately, both pass, and concludes no predecessor matters. What did that reasoning miss?
Show answer and explanation
- An interaction requiring the combined ordered predecessor sequence
- That no predecessor context matters
- That deleting both predecessors is justified by their individual passing reduction runs
- That T must have failed without any predecessor because neither half reproduces it
Answer: An interaction requiring the combined ordered predecessor sequence
Failure-inducing context need not be attributable to one predecessor. Reduction must preserve and test interactions rather than assume separability.
87.A suite shard key is
hash(testID)mod 4. The language's process hash salt changes per run. What would make membership reproducible across workers and replays?Show answer and explanation
- A stable test ID alone, assuming every language hash of that ID is cross-process stable
- Only the same worker count
- The same modulo operation with independently randomized salts in each worker
- A specified stable hash algorithm and fixed input encoding
Answer: A specified stable hash algorithm and fixed input encoding
A stable test ID is insufficient if its hashing changes. Specify the hash and encoding used to assign each test.
88.Three tests take 9,6,3 units. They run on two workers without setup cost, and tests cannot be split. Which assignment has minimum possible makespan?
Show answer and explanation
- One worker runs 9; the other runs 6 then 3, finishing at 9
- One worker runs all three, finishing at 18
- One worker runs 9 then 6; the other runs 3, finishing at 15
- One worker runs 9 then 3; the other runs 6, finishing at 12
Answer: One worker runs 9; the other runs 6 then 3, finishing at 9
Total work is 18, so two workers need at least 9 units. The 9 versus 6+3 assignment attains that bound.
89.A report labels a test passed if any of three attempts passes. Each attempt independently fails with probability 1/2. What probability does the report show a failure for that test?
Show answer and explanation
- 3/8
- 1/2
- 1/8
- 7/8
Answer: 1/8
The report fails only if all three attempts fail. Independence gives (1/2)^3=1/8, even though the underlying per-attempt failure probability remains 1/2.
90.A rerun policy classifies failures after rebuilding the app and replacing the dataset. A second run passes. What inference about the original failure is supported?
Show answer and explanation
- The first failure has been reproduced, despite the replacement build and dataset
- The changed-condition rerun alone does not establish a flaky original case
- The changed build is the sole cause of recovery, despite the simultaneous dataset change
- That the original case is proven flaky
Answer: The changed-condition rerun alone does not establish a flaky original case
Several relevant conditions changed. A passing rerun cannot by itself show that one unchanged configuration produces both outcomes.
91.A property-test shrinker must retain input rule a<b. It proposes (a,b)=(4,1), which fails validation before the target logic. What should the shrink predicate require?
Show answer and explanation
- The domain precondition and the target failure both still hold
- Any exception after shrinking
- Any failure after shrinking, without retaining the invariant required to reach target logic
- Only a smaller serialized input, even if it violates the supported command preconditions
Answer: The domain precondition and the target failure both still hold
A useful reduced reproducer preserves validity and the same target failure. A smaller invalid setup is a different case.
92.A replay log records event arrival times but not the tie-breaking order for two events with equal times. Processing order affects the result. What field completes this ordering evidence?
Show answer and explanation
- A sequence number or recorded order within equal-time events
- Only the equal timestamp values
- Only the number of events at that time, without preserving their order
- A sorted order invented during replay, even when it differs from the failure’s processing order
Answer: A sequence number or recorded order within equal-time events
Equal timestamps do not define a total order. Preserve the actual tie order when that order affects behavior.
93.A test matrix declares client modes {old,new} and cache states {cold,warm}. One sharding bug drops every cold case. All executed tests pass. What evidence reveals this omission?
Show answer and explanation
- Only the executed tests’ pass rate
- Compare discovered/executed case IDs with the expected matrix
- Only the assertion count of executed warm cases, without checking expected case identities
- Only aggregate pass rate, using executed cases as the denominator despite dropped cold cases
Answer: Compare discovered/executed case IDs with the expected matrix
A passing subset does not establish that every intended case ran. Inventory comparison detects missing cold configurations.
94.A test-selection map tracks imports, but schema file S is loaded by filename at runtime and is absent from that map. S changes. What does a sound selection rule need to include?
Show answer and explanation
- That runtime dependency or a conservative fallback for S changes
- Only test-source modifications, assuming changed data cannot affect unchanged test code
- Only the static import graph
- Only previously failing tests, even when no consumer of S failed in the previous run
Answer: That runtime dependency or a conservative fallback for S changes
Selection is only as complete as its dependency model. Runtime-loaded inputs need explicit edges or a fallback that does not omit their consumers.
95.A fixture uses a fixed account for a serial sequence of dependent steps. The runner randomizes those steps independently across workers. How should this intended workflow be modeled?
Show answer and explanation
- As separate tests that assume earlier names run first
- As one explicitly ordered scenario with isolated state
- As independent tests sharing the account without dependencies
- As unrelated tests whose ordering is repaired with sleeps
Answer: As one explicitly ordered scenario with isolated state
Some workflows intentionally have sequential state. Express the sequence inside an owned scenario rather than hiding cross-test ordering assumptions.
96.A deterministic test's fake clock returns one value to the validator, then a later value to the writer. The production operation's contract requires one captured decision time shared by both. What should the test verify?
Show answer and explanation
- That the test never invokes the writer after validation
- That both decisions use the same captured operation timestamp
- That the validator and writer use unrelated time zones
- That every clock read always returns the latest possible value
Answer: That both decisions use the same captured operation timestamp
The contract is an atomic time snapshot for the operation. A changing clock fake can reveal an implementation that incorrectly rereads time between decisions.
97.An artifact receipt stores a mutable branch name as 'tested version'. The branch later advances. What should be recorded to identify the actual tested application?
Show answer and explanation
- An immutable commit or artifact digest, plus relevant build inputs
- Only the mutable branch name
- The newest build on the branch at replay time, regardless of which build originally failed
- Only the test report’s creation time, without mapping it to a specific immutable artifact
Answer: An immutable commit or artifact digest, plus relevant build inputs
A moving reference does not uniquely identify the tested bytes. Preserve immutable identity and the inputs needed to reconstruct the artifact.
98.A deterministic scheduler emits a trace only for the test thread. An untracked background worker writes shared state, causing unreplayable failures. What ownership change is needed?
Show answer and explanation
- Only the final state, discarding the unrecorded background writes that produced it
- More replays of the same partial trace without constraining the background worker
- Bring relevant background work into controlled execution or record its effects
- Only the existing partial trace
Answer: Bring relevant background work into controlled execution or record its effects
Deterministic control has a scope. Relevant untracked actors must be controlled or their input effects captured to make replay meaningful.
99.A harness replaces all concurrent execution with one fixed serial schedule. The supported program can deadlock only when both locks are held concurrently. What limit should its passing result acknowledge?
Show answer and explanation
- That every concurrent schedule is safe
- That the selected serial schedule does not exercise the deadlocking overlap
- Repeating the same serial schedule eventually proves that all concurrent schedules are safe
- The production program cannot deadlock because the harness removed concurrent overlap
Answer: That the selected serial schedule does not exercise the deadlocking overlap
A deterministic schedule can be useful without being exhaustive. This schedule excludes the overlap required by the supplied failure mechanism.
100.A controlled test runs exactly 10,000 identical schedules with identical inputs and state. All pass. How many distinct schedules does that observation cover?
Show answer and explanation
- 10,000
- 1
- At least 10,001
- Every schedule allowed by the program
Answer: 1
Repetition increases observations of one execution arrangement, not schedule diversity. Exploring other schedules requires changing the controlled decisions.
101.A test receipt must replay a failure caused jointly by a stale cache entry, a delayed reply and a generated input. Which package of evidence covers these stated causes?
Show answer and explanation
- Only the reply payload, omitting the starting cache entry and generated input
- Initial cache state, input/generator identity, and relevant reply schedule
- Only the final cache contents, omitting the state and schedule that produced the failure
- Only the input and final exception
Answer: Initial cache state, input/generator identity, and relevant reply schedule
Replay needs the relevant starting state, input and ordering. Capturing only one of those leaves the stated interaction uncontrolled.