Verified against GitHub Copilot Chat · 2026-08-12
Write an integration test plan for a multi-service flow, not just another mocked unit test
Gets Copilot Chat to design an integration test that exercises a real multi-step flow across actual dependencies — a database, a queue, a second internal service — instead of quietly producing another unit test with everything mocked out.
The prompt
Ready to copy — highlighted parts are example details you can swap.
You are designing an integration test for a flow that spans more than one component in this system, where the point of the test is to catch failures that only show up when the real pieces talk to each other — not a unit test with every dependency mocked, which would miss exactly the class of bug this test needs to catch. FLOW TO TEST A user submits an order, which writes to the orders table, publishes an OrderCreated event to the queue, and the inventory service consumes that event to decrement stock. DEPENDENCIES THAT MUST BE REAL, NOT MOCKED Postgres (via a test database), the real RabbitMQ instance running in the test environment, and the actual inventory service — not a stub of it. SPECIFIC FAILURE POINTS THIS SHOULD CATCH The queue event was published before the database transaction committed, so the inventory service sometimes processed an order that didn't fully exist yet. TEST ENVIRONMENT AVAILABLE Testcontainers spins up Postgres and RabbitMQ per test run; the inventory service runs locally via docker-compose.test.yml. PHASE 1 — CONFIRM WHAT 'INTEGRATION' MEANS FOR THIS FLOW Before writing any test code, state back which components will be exercised for real versus which (if any) still need to be mocked because they're genuinely external to this system (a third-party payment processor sandbox, for example, might reasonably still be a mock or a recorded fixture) — and justify each mock against the failure points listed, so a mock is never added just because it's more convenient to write around. PHASE 2 — SETUP AND TEARDOWN Describe how the test environment gets into a known state before the test runs and back to clean afterward — using the test environment described above — since an integration test that leaves state behind will produce flaky, order-dependent failures in every test that runs after it, which is a worse outcome than not having the test at all. PHASE 3 — THE TEST ITSELF Write the test so it exercises the flow end to end through the real dependencies, asserting on outcomes that could only be wrong if the real integration between components broke — not on internal implementation details that a unit test would already cover. For each of the specific failure points listed, make sure there's an assertion that would actually fail if that specific failure happened; a passing integration test that wouldn't have caught the incident it was written in response to isn't accomplishing anything. PHASE 4 — WHAT THIS TEST DELIBERATELY DOES NOT COVER State explicitly what's still out of scope for this test (edge cases already handled by unit tests, load/concurrency behavior, etc.) so nobody mistakes this one test for full coverage of the flow. OUTPUT FORMAT 1. Mock justification (Phase 1). 2. Setup/teardown code. 3. The integration test itself. 4. Explicit out-of-scope note (Phase 4).
Customize
Optional — swap in your own details for the highlighted parts above.
Why this works
Asked for an 'integration test' with no further constraint, Copilot Chat frequently produces something that is structurally a unit test with a slightly larger surface area — every collaborator mocked, assertions checking that the right mock methods were called rather than that real systems actually agree with each other — because that pattern dominates what 'test' generally means in most training data, and the model has no way to know which of your dependencies are the actual point of the test versus incidental plumbing unless told. Requiring an explicit mock-justification phase before any test code gets written forces that judgment call into the open where you can correct it, rather than discovering three weeks later that the 'integration test' for a queue-consumer flow mocked the queue itself and would never have caught the exact ordering bug it was written to catch. Tying each failure point to a specific required assertion addresses the most common way integration tests silently stop being useful: a test can pass indefinitely while asserting on details that have nothing to do with the actual incident it was supposed to guard against, and without being forced to trace each named failure point to a concrete assertion, Copilot Chat will tend to write generically 'reasonable-looking' assertions that happen not to cover the case that matters. The explicit out-of-scope phase matters organizationally more than technically: a team that reads 'we have an integration test for this flow' tends to over-trust its coverage unless the test itself states plainly what it does not check, and that overconfidence is exactly how gaps get left unaddressed for months after a single integration test was added and assumed to be sufficient.
What you get back
Mock justification: Postgres, RabbitMQ, and the inventory service all run for real via testcontainers/docker-compose — nothing here is mocked, since the failure point (event published before commit) only manifests when the real transaction-commit timing interacts with the real queue delivery. Test: creates an order via the real order-creation path, asserts the DB row exists AND was committed before asserting the queue message was consumed, specifically checking commit-then-publish ordering rather than just checking both eventually happened. Out of scope: this test does not cover concurrent order creation under load, or the inventory service's own unit-level decrement logic, which is already covered elsewhere.
Verified against
GitHub Copilot Chat 2026.08 · 2026-08-12
Changelog
- 2026-08-12 — Initial publish, verified against GitHub Copilot Chat 2026.08.
Need this built into your business?
If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.
EXPLORE CUSTOM SOFTWARE
