Software QA / Intermediate: integrated product evidence / Lesson 14
Test doubles and real dependency contracts
Use controlled fakes to test behavior while checking their assumptions at the real dependency boundary.
On this page
Lesson goals
- Choose a suitable test double for a bounded question.
- Inspect outcomes and side effects.
- Verify fake assumptions at an isolated integration boundary.
- Select a double for a controlled question and state its assumptions and limits.
- Design timeout reconciliation and isolated contract checks with observable effects.
Why substitute a dependency
A test double replaces a collaborator so a test can control its responses and inspect a limited interaction. A payment service or seat allocator may be slow, unavailable, or difficult to place into a timeout state. In an isolated synthetic enrollment example, a small fake lets a test exercise both acceptance and timeout handling deterministically. The fake is a tool for a specific question; it does not establish that a real remote provider behaves the same way.
Define a narrow fake contract
Write down the interface and response semantics the application expects before implementing a fake. For a seat request, agree on the input identifier, the accepted response, and whether a timeout leaves the outcome unknown. Program only the responses needed by the case and make unexpected inputs fail visibly. The illustrative table separates a controlled fake response from the business result. The real system may have additional states, so this narrow table is not its complete specification.
Scenario | Fake response | Expected observation
available seat | accepted | one enrollment
service timeout | timeout | no confirmed enrollment
The table separates the controlled scenario from the evidence it can provide.
Observe behavior and side effects
After the action, inspect both the result shown to the caller and the synthetic store. A timeout does not necessarily prove that a real external service performed no work: the response can be lost after processing. The test must reflect the documented reconciliation rule rather than silently assume no effect. For the fake scenario, assert the requested identifier and the resulting local state, but avoid asserting irrelevant internal call order that a safe refactor could change.
Check the real boundary too
Use an additional integration or contract check against an authorized isolated instance or provider-supplied test environment where available. It should verify that the actual response and error formats match the assumptions made by the fake, including a meaningful negative case. Never use real accounts or payments as disposable fixtures. A fake passing and an integration check failing identifies a mismatch for investigation; it does not by itself identify whether the implementation, documentation or fake is wrong.
Layer | Dependency | Evidence
unit | local fake | decision and requested input
integration | real isolated service | actual contract and persistence
The table separates the controlled scenario from the evidence it can provide.
Maintain and retire assumptions
Keep fake behavior near the contract it represents and assign an owner for reviewing it after provider changes. Record which behaviors are simulated and which are observed at the real boundary. When a repaired incident exposes a missing response case, add a focused regression with an independently stated expected outcome. Remove obsolete fake modes when the contract changes, and rerun the relevant integration check. These complementary observations improve confidence while leaving network schedules and untested provider behavior explicitly outside the claim.
Choose a substitute for a specific question
A test double replaces a collaborator so a test can control a condition or observe an interaction. A stub can return a predetermined timeout, a fake can maintain a simplified in-memory seat ledger, and a mock can verify a relevant request. Teams use these names differently, so describe what the substitute actually does. The question determines the choice: a local timeout response can exercise the caller’s handling, while a stateful fake can explore repeated reservations. Neither establishes the real provider’s behavior.
Write the expected local outcome before configuring the double. For a synthetic reservation request, an accepted response may produce one local enrollment; a timeout may leave the external outcome unknown under the agreed reconciliation rule. Do not silently equate missing response with no external effect. Label every fixture and trace in this lesson as a hypothetical design, not an executed provider interaction.
Specify the narrow simulated contract
Record the dependency’s agreed input fields, permitted values, response states, errors, and side-effect assumptions. A fake for a seat service might accept a synthetic course identifier and return an allocation identifier, but its small set of modes is not a complete provider specification. Make unexpected input visible rather than returning success for everything. A fake that accepts an invalid identifier can mask an application defect.
Use explicit fixtures for accepted, rejected, and timeout outcomes, and keep their initial state independent. If the fake has a ledger, define whether a repeated key returns an existing allocation or creates a new one according to the application contract. State key scope and retention assumptions rather than inventing them. A controlled mode supports a reproducible question only within those assumptions.
Model a timeout as an uncertain outcome
A timeout is an observation at the caller: the response was not received within its limit. The provider might have rejected the request, committed it and lost the response, or still be processing it. A useful local test selects a specific simulated condition and asserts the caller’s status, stored state, and next reconciliation action. Do not claim that the selected fake behavior covers all possible external outcomes.
For a provider contract that supports lookup by operation key, simulate a committed allocation with a lost response, then return that allocation on lookup. Expect one local confirmation and no second allocation after reconciliation. Also design a separate case for a confirmed absent operation if the contract defines it. A matching retry response alone does not establish that only one external effect occurred.
Assert the contract rather than incidental internals
An interaction assertion is useful when the interaction itself is an obligation, such as sending the agreed operation key and amount to a payment boundary. Check the meaningful arguments and the observable result or persisted effect. A call-count assertion alone can pass with the wrong amount, and a correct request does not establish that a real provider accepted it. Independently derive expected amounts and identify any rounding assumptions.
Avoid fixing every internal helper call order when the contract concerns one final enrollment. A harmless refactor could reorder private calls without changing the result. Conversely, exactly one provider request may be an explicit safety rule in a particular scenario, in which case count is meaningful. Each assertion should explain the harmful outcome it could detect.
Verify assumptions at an isolated real boundary
Complement fake-based checks with a contract or integration check against an authorized isolated service or provider test environment when available. Verify actual request and response formats, required identifiers, negative cases, and persistence behavior using synthetic data. If a fake accepts an identifier the isolated service rejects, compare both with the agreed contract and investigate whether the fake, application, documentation, or configuration is wrong. The mismatch alone does not identify the culprit.
Record dependency version, configuration, credentials scope without secrets, and the exact contract revision. A provider sandbox may itself differ from production and cannot prove every network schedule. If it is unavailable, mark integration blocked; a local fake pass remains evidence only for the simulated behavior. Never send real payments or use private user records as disposable test fixtures.
Maintain a useful model of the collaborator
Assign ownership of fake assumptions and review them when a dependency changes. A new required field, changed error code, or different idempotency scope can make a formerly useful fake misleading. Keep the fake close to its contract examples and include a meaningful negative mode; an always-successful fake cannot exercise refusal or recovery. Retire obsolete modes only after understanding which risk they covered.
After a confirmed mismatch is repaired, retain a focused regression at the appropriate boundary and rerun the relevant local case. Report what was simulated, what was observed at the isolated service, and what remains untested. A planned trace is not execution evidence, and a successful local case does not eliminate uncertainty about real provider failures or concurrency.
20 worked examples
1. Controlled acceptance
Problem: Analyze the synthetic controlled acceptance scenario and determine the double outcome or contract evidence limit.
- The fake supplies the agreed accepted response for C1.
- The local rule maps that response to one synthetic enrollment.
fake: reserve(C1) -> accepted allocation=A1
local rule: accepted allocation creates one enrollment
expected local rows=1
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Expect one local enrollment linked to A1.
Why this result follows: The fixture tests caller behavior under a controlled acceptance, not real provider availability.
2. Controlled refusal
Problem: Analyze the synthetic controlled refusal scenario and determine the double outcome or contract evidence limit.
- The controlled response is refusal rather than acceptance.
- The stated local rule forbids creating an enrollment for that response.
fake: reserve(C1) -> full
local rule: full creates no enrollment
initial local rows=0
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Expect a capacity message and zero local rows.
Why this result follows: A negative fake mode exercises a path an always-successful substitute cannot reach.
3. Timeout before simulated effect
Problem: Analyze the synthetic timeout before simulated effect scenario and determine the double outcome or contract evidence limit.
- The fake was configured to create no allocation in this mode.
- The caller still follows the documented uncertain-outcome policy.
fake mode: timeout; fake ledger remains empty
local rule: status pending until reconciliation
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Expect pending local status and no confirmed enrollment.
Why this result follows: The simulated ledger state is a fixture assumption, not proof of real timeout semantics.
4. Timeout after simulated effect
Problem: Analyze the synthetic timeout after simulated effect scenario and determine the double outcome or contract evidence limit.
- The fake has already recorded the allocation before withholding the response.
- Lookup returns the existing identity rather than requiring a second allocation.
fake ledger: key=K allocated A1
response withheld -> timeout
lookup(K) -> A1
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Expect reconciliation to confirm A1 once.
Why this result follows: This case exposes the risk of treating a lost response as proof that no work occurred.
5. Unknown unexpected request
Problem: Analyze the synthetic unknown unexpected request scenario and determine the double outcome or contract evidence limit.
- C9 is outside the narrow fixture contract.
- Returning success would hide that the caller sent a different identifier.
fake contract: accepts only course C1
caller sends course C9
fake configured to fail unexpected input
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: The fake should flag the unexpected request.
Why this result follows: A strict boundary makes incorrect test inputs visible instead of producing false confidence.
6. Always-successful fake
Problem: Analyze the synthetic always-successful fake scenario and determine the double outcome or contract evidence limit.
- The substitute accepts an input the contract forbids.
- A passing local test can therefore conceal the caller’s invalid request.
fake: accepts every identifier
caller sends invalid empty identifier
provider contract: identifier required
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: The fake is too permissive for this validation risk.
Why this result follows: A meaningful negative mode and boundary check challenge fake assumptions. The conclusion is scoped to this stated contract and fixture.
7. Wrong amount with call count
Problem: Analyze the synthetic wrong amount with call count scenario and determine the double outcome or contract evidence limit.
- The interaction count matches one request.
- The amount differs from the independently expected 6000 cents. This follows from the stated synthetic contract.
expected request: amount=6000 cents
observed fake call: amount=12000, count=1
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Fail the request contract despite one call.
Why this result follows: Checking meaningful arguments detects a financial error that call count alone misses.
8. Incidental helper order
Problem: Analyze the synthetic incidental helper order scenario and determine the double outcome or contract evidence limit.
- The business obligation specifies the final resource.
- It does not prescribe the private helper sequence in this fixture.
contract: one local enrollment for A1
refactor changes private helper order
final local enrollment unchanged
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: The stated final contract remains satisfied.
Why this result follows: Avoiding incidental ordering assertions permits safe refactoring without weakening the outcome check.
9. Required interaction count
Problem: Analyze the synthetic required interaction count scenario and determine the double outcome or contract evidence limit.
- The lookup already resolved the uncertain operation.
- A further allocation request violates the explicit no-second-request obligation.
contract: no second allocation request after successful lookup
trace: lookup returns A1; allocate called again
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Fail the specified interaction rule.
Why this result follows: A call count is meaningful when it protects a documented duplicate-effect risk.
10. Response equality not enough
Problem: Analyze the synthetic response equality not enough scenario and determine the double outcome or contract evidence limit.
- The response identities match.
- The ledger nevertheless contains a second effect for the same operation key.
retry responses both allocation=A1
fake ledger contains A1 and A2
contract: one allocation per key
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Fail: two allocations violate the contract.
Why this result follows: Inspecting state catches duplication hidden by repeated response bodies. The conclusion is scoped to this stated contract and fixture.
11. Changed body same key
Problem: Analyze the synthetic changed body same key scenario and determine the double outcome or contract evidence limit.
- The retry uses the same key but a different course.
- The agreed rule binds the key to the original request body.
contract: same key plus changed course -> conflict
first K/C1; retry K/C2
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Expect conflict and no C2 allocation.
Why this result follows: A changed-body case tests key semantics separately from an identical retry. The conclusion is scoped to this stated contract and fixture.
12. Per-actor key scope
Problem: Analyze the synthetic per-actor key scope scenario and determine the double outcome or contract evidence limit.
- The key text is the same but the actor scope differs.
- The stated contract does not merge their allocations.
contract: operation keys scoped to actor
A/K reserves C1; B/K reserves C2
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Expect independent A and B operations.
Why this result follows: Scope is part of the oracle for identifying whether two requests represent one operation.
13. Retention unspecified
Problem: Analyze the synthetic retention unspecified scenario and determine the double outcome or contract evidence limit.
- The elapsed time is known.
- The fixture does not define whether the key remains valid after thirty days.
key K used yesterday; repeated after 30 days
contract retention=unspecified
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Ask the owner for retention behavior before asserting replay.
Why this result follows: A precise retry expectation needs an agreed lifetime as well as matching key text.
14. Fake and service mismatch
Problem: Analyze the synthetic fake and service mismatch scenario and determine the double outcome or contract evidence limit.
- The two boundaries produce different outcomes for the same synthetic input.
- Without an agreed format, neither result alone identifies the incorrect component.
fake accepts id="abc"
isolated service rejects id="abc"
agreed identifier format=unresolved
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Investigate the discrepancy against the contract owner.
Why this result follows: Recording both observations and the missing rule avoids blaming the fake or service prematurely.
15. Required response field drift
Problem: Analyze the synthetic required response field drift scenario and determine the double outcome or contract evidence limit.
- The current fake response omits a field required by the revised contract.
- A caller tested only with it may not exercise the real response shape.
provider contract v2 requires allocation_id
fake v1 returns accepted without allocation_id
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Update and review the fake assumption for v2.
Why this result follows: Versioned contract review prevents stale substitutes from silently misleading tests. The conclusion is scoped to this stated contract and fixture.
16. Safe provider error
Problem: Analyze the synthetic safe provider error scenario and determine the double outcome or contract evidence limit.
- The service returned the required error category for the invalid synthetic identifier.
- The fixture states that no internal trace is exposed.
isolated test service: invalid id -> error code=INVALID
contract: INVALID without internal trace
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: The response matches the stated negative error contract.
Why this result follows: A real-boundary negative case complements local fake tests for error behavior. The conclusion is scoped to this stated contract and fixture.
17. Sandbox unavailable
Problem: Analyze the synthetic sandbox unavailable scenario and determine the double outcome or contract evidence limit.
- The local case observes handling of a programmed response.
- The provider boundary was not exercised while the sandbox was unavailable.
local fake timeout case=passed
isolated provider test=blocked
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Report local evidence and blocked provider check separately.
Why this result follows: A substitute pass cannot turn an unexecuted integration check into provider evidence.
18. Fake ledger reset
Problem: Analyze the synthetic fake ledger reset scenario and determine the double outcome or contract evidence limit.
- A1 persists from the previous case in the shared fake.
- B’s empty-ledger assumption is therefore false.
case A creates fake allocation A1
case B expects empty ledger
ledger shared and not reset
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Case B has contaminated starting state.
Why this result follows: Fake dependencies need explicit fixture ownership and reset just like other mutable state.
19. Wrong response ordering
Problem: Analyze the synthetic wrong response ordering scenario and determine the double outcome or contract evidence limit.
- B is the latest accepted request in the synthetic sequence.
- The final display reverts to the older A response.
fake returns response for request B before A
local rule: latest accepted request remains displayed
final display=A
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: Fail the stated latest-request display rule.
Why this result follows: A controlled double can expose ordering behavior without asserting real network timing.
20. Planned integration
Problem: Analyze the synthetic planned integration scenario and determine the double outcome or contract evidence limit.
- The fixture specifies an intended request and oracle.
- It contains no observation from the isolated provider.
contract case and synthetic request written
provider environment not contacted
The hypothetical fixture supplies double behavior and contract for analysis.
Expected result: The integration check is planned, not passed.
Why this result follows: Design artifacts must be distinguished from executed boundary evidence. The conclusion is scoped to this stated contract and fixture.
Common errors and fixes
Treating a fake as proof of provider behavior
- Why it happens
- A locally programmed response can diverge from the real contract.
- How to fix it
- Run a separate isolated integration or contract check.
- Prevent it next time
- Review fake assumptions after dependency changes.
Assuming a timeout means no external effect
- Why it happens
- The response can be lost after the operation.
- How to fix it
- Test reconciliation against the agreed contract.
- Prevent it next time
- Model uncertain outcomes explicitly.
Asserting every internal call
- Why it happens
- The test encodes incidental implementation details.
- How to fix it
- Assert relevant requests and observable outcomes.
- Prevent it next time
- Review whether each interaction is a required contract.
20 practice exercises
1. A fake always accepts requests. Which scenario is missing?
Show hint
Add a controlled timeout with explicit local and reconciliation outcomes.
Show worked solution
Add a controlled timeout and state the expected local outcome and reconciliation behavior. An always-successful fake cannot exercise error handling.
An always-successful fake cannot reach the error path. Configure a synthetic timeout, state whether the external outcome is unknown, and check local state and reconciliation according to the contract. Keep this simulation separate from evidence about the real provider.
Check your solution
- Timeout is a separate controlled mode.
- Agreed local state and reconciliation are checked.
2. The fake accepts an identifier that the isolated service rejects. What should the team do?
Show hint
Compare the request and both responses with the agreed revision before assigning blame.
Show worked solution
Compare the agreed interface, request and error response, then correct the fake or implementation according to the contract. Retain a regression check at the real boundary.
Preserve the synthetic identifier, fake response, isolated service response, contract versions, and configuration. Compare the identifier format and error with the specification, correct the responsible component, and retain a real-boundary regression after the repair.
Check your solution
- Fake and service responses are recorded.
- The contract is reviewed and a real-boundary regression retained.
3. A fake seat service always returns success. Design a refusal case and its local state oracle.
Show hint
Control a negative response explicitly.
Show worked solution
Configure the fake to return full for a synthetic course with no capacity. Expect the agreed capacity message and no new local enrollment, and verify the starting store was empty. This local case tests handling of that programmed response; it does not establish that the real service returns the same error.
Check your solution
- Fake returns full
- No local enrollment is created
4. A payment fake returns timeout. What should a caller report if the external effect is unknown?
Show hint
A missing response is not proof of no charge.
Show worked solution
Expect the agreed pending or uncertain status rather than asserting that no external charge occurred. Record the synthetic operation key and test the documented reconciliation path separately. The fake’s chosen ledger state must be explicit, because another timeout scenario could commit before the response is lost.
Check your solution
- Outcome is marked uncertain
- Reconciliation is checked separately
5. Simulate an allocation committed before its response is lost. Design the next controlled observation.
Show hint
Look up the existing operation by its agreed key.
Show worked solution
Configure the fake ledger with allocation A1 for synthetic key K, withhold the initial response, and return A1 on lookup. Expect one local confirmation and no second allocation request under the stated reconciliation rule. Record the final ledger count; the scenario remains simulated provider behavior.
Check your solution
- Lookup returns A1
- Only one allocation remains
6. A fake accepts an empty identifier although the agreed provider contract requires one. What test improvement is needed?
Show hint
Unexpected inputs should be visible.
Show worked solution
Configure the fake to reject or flag the empty identifier according to the agreed contract, then verify that the caller sends a valid synthetic identifier. Add an isolated boundary negative case to check the real service response. Do not assume the fake’s previous permissive behavior was authoritative.
Check your solution
- Empty identifier is rejected or flagged
- Real boundary negative case is separate
7. A mock verifies one payment call but ignores its 9000-cent amount; the expected amount is 4500. Assess the test.
Show hint
Count and argument are different obligations.
Show worked solution
The call-count check passes even though the amount is twice the independent expected value. Assert the relevant amount and operation identifier as well as any contractually required count, and inspect the local outcome. A real provider integration check remains separate from this mock interaction.
Check your solution
- One call does not validate amount
- Expected amount is 4500 cents
8. A refactor changes the order of private helper calls but preserves one correct enrollment. Should a call-order test necessarily fail?
Show hint
Ask whether order is part of the contract.
Show worked solution
If the agreed contract specifies only the final enrollment and no required helper sequence, remove or relax the incidental order assertion and verify the outcome instead. Retain an interaction assertion when a particular ordering protects a documented safety rule. Evaluate the requirement rather than assuming every internal call is observable behavior.
Check your solution
- Final enrollment is checked
- Only required order is asserted
9. A lookup returns existing allocation A1 after a timeout, but the caller sends another allocation request. Assess the agreed no-duplicate rule.
Show hint
Reconciliation already resolved the operation.
Show worked solution
Fail the interaction case if the contract explicitly forbids another allocation after a successful lookup. Record the synthetic key, lookup result, subsequent request, and final fake ledger count. This is a meaningful interaction assertion because a second request could create a duplicate effect.
Check your solution
- Lookup returned A1
- Second allocation request violates the rule
10. Two retry responses both show A1, but the fake ledger contains A1 and A2. What should be asserted?
Show hint
Inspect effects as well as responses.
Show worked solution
Fail the one-allocation-per-key case because the ledger contains two synthetic allocations despite matching response identities. Assert the final count and ownership for the key alongside the response. Preserve the request sequence so the team can distinguish duplicate storage from a display-only discrepancy.
Check your solution
- Responses both show A1
- Two allocations violate one-effect rule
11. Key K was used for C1 and is reused with C2; the contract specifies conflict. Design the fake case.
Show hint
Change only the request body.
Show worked solution
Seed the fake with K bound to synthetic course C1, then request C2 with K. Expect the agreed conflict and no C2 allocation, while the original C1 allocation remains. Test an identical-body retry separately because it answers a different idempotency question.
Check your solution
- Changed body gets conflict
- No C2 allocation is added
12. Two actors use the same key text under a per-actor key contract. What should the fake preserve?
Show hint
The actor is part of the key scope.
Show worked solution
Maintain separate synthetic ledger entries for actor A with key K and actor B with key K, and return each actor’s own allocation. Verify that B cannot receive A’s identifier. This expectation depends on the stated per-actor scope and must be checked separately at the real boundary.
Check your solution
- A and B have distinct key scopes
- Each receives its own allocation
13. A key is retried after 60 days, but retention is unspecified. How should the test author proceed?
Show hint
Do not invent a lifetime.
Show worked solution
Record that replay versus a new operation is unresolved and ask the contract owner to define retention and expiry behavior. Once agreed, design cases before and at the relevant boundary with a controlled clock. Do not copy a fake’s arbitrary retention period into the expected result.
Check your solution
- Retention is unresolved
- Boundary cases follow an agreed rule
14. The fake accepts identifier X while an isolated service rejects X. Plan an evidence-based investigation.
Show hint
A mismatch does not identify the culprit.
Show worked solution
Preserve the synthetic request, fake response, isolated service response, versions, and configuration. Compare each with the agreed identifier format and ask the owner to resolve any ambiguity. Correct the fake, application, documentation, or environment as indicated, then retain a real-boundary regression for the agreed behavior.
Check your solution
- Both outcomes are recorded
- Contract and configuration are reviewed
15. A provider adds a required response field. What maintenance is needed for the fake and tests?
Show hint
Review assumptions against the revised contract.
Show worked solution
Update the fake’s response modes and consumer expectations to reflect the reviewed required field, and check how the application handles its absence as a negative case. Run an authorized isolated contract check against the provider test environment. Record the contract version so old local passes are not mistaken for current integration evidence.
Check your solution
- Fake reflects the new required field
- Real-boundary compatibility is checked
16. A provider sandbox is unavailable while local fake tests pass. Write the evidence statement.
Show hint
A blocked boundary has no observed provider result.
Show worked solution
Report the local fake cases and their configured responses as simulated evidence, and mark the isolated provider check blocked by the unavailable sandbox. Name the affected workflow and planned retest. Do not claim current provider compatibility or timeout behavior from the local pass alone.
Check your solution
- Local results are labeled simulated
- Provider check is blocked
17. Two tests share a stateful fake ledger and the first leaves an allocation behind. How can they be isolated?
Show hint
Treat the fake as mutable fixture state.
Show worked solution
Create a fresh ledger per independent case or reset only its owned synthetic entries during teardown, including after failure. Assert the expected empty starting state for the second case and rerun the pair in both orders. Avoid a broad reset if other parallel tests share the same store.
Check your solution
- Second case starts with an empty ledger
- Cleanup does not delete another case’s data
18. A fake delays the first search response until after a second response. What should the local assertion inspect?
Show hint
Check final identity after both responses.
Show worked solution
Under the agreed latest-query rule, inspect the final query label and result identifiers after both controlled responses arrive. The earlier response must not overwrite the later query’s results. Record the artificial ordering and avoid claiming that the fake reproduces every real network schedule.
Check your solution
- Final label matches latest query
- Result identifiers match the latest response
19. A local fake test passes, but no isolated provider call was made. Write a bounded claim.
Show hint
Name the substituted dependency.
Show worked solution
Report that the caller handled the configured fake response for the specified synthetic input on the recorded build. State that actual provider format, persistence, and network behavior were not observed. A local pass is useful for the bounded decision but cannot establish real integration compatibility.
Check your solution
- Fake response and input are named
- Real provider remains untested
20. A contract test is designed for an isolated provider but has not run. How should its status be reported?
Show hint
A designed case is not a result.
Show worked solution
List the intended synthetic request, expected contract response, dependency version, and environment as planned work. Mark the provider check not executed and identify the risk that remains unverified. Do not count an agreed example or fake test as a passing provider observation.
Check your solution
- Provider case is not executed
- Unverified risk is named
Key takeaways
- A controlled fake supports a specific test question.
- Integration evidence checks assumptions the fake cannot establish.
- A timeout does not prove that no external effect occurred.
- Assert contract arguments and state rather than incidental helper order.
- Provider compatibility needs separate evidence at its isolated real boundary.