In the pack: ChatGPT, Claude & Gemini Prompts for Coding and Developers
Test Code With External Dependencies Using Fakes and Mocks
Prompt
Test framework: {{TEST_FRAMEWORK}}
Code under test: {{CODE}}
The behaviors I most need to verify, including failures (timeouts, 500 errors, empty results): {{BEHAVIORS}}
Do this:
1. List each external dependency in the code and recommend how to handle it in tests: a real instance (such as an in-memory or containerized database), a fake (a simple working implementation), a stub (canned answers), or a mock (checks calls). Explain the choice for each.
2. If the code is hard to test because a dependency is created inside it, show the smallest refactor that allows it to be injected.
3. Write tests for my behaviors, including at least two failure modes of each dependency.
4. Avoid over-mocking: don't assert on internal call sequences unless the call itself is the behavior (for example, "an email was sent once").
5. Say which risks these tests don't cover and should be covered by an integration or contract test instead.
Use only my framework and the standard library's test helpers unless I approve a new dependency.
Customize this prompt
Fill in the variables below to personalize this prompt:
Model Settings
Recommended Models
Temperature
Max Tokens
Additional Notes
About this prompt
“Test Code With External Dependencies Using Fakes and Mocks” is a free prompt for ChatGPT in the Coding & Software category, 201 words long, added to The Prompt Index on October 28, 2026 by The Prompt Index. Copy it with the button above, paste it into ChatGPT or any other AI chat assistant, and send it.
It has 4 placeholders to fill in first:
{{LANGUAGE}}, {{TEST_FRAMEWORK}}, {{CODE}}, {{BEHAVIORS}}.
Use the “Customize this prompt” fields to personalise it before you copy.
Recommended models: ChatGPT, Claude, Gemini.
0 upvotes, sent to an AI tool 0 times, viewed 3 times.
Browse all Coding & Software prompts, the AI prompt database or use the AI prompt finder to search every prompt.