Tests & Docs AI Prompts
4 ready-to-use prompts — pick a tool, copy, and go
Prompt Templates by Tool
Why ChatGPT?
ChatGPT writes comprehensive tests and clear documentation that match your codebase's style and framework conventions. It understands what edge cases to cover and writes docs that developers actually want to read.
Learn more about ChatGPT → Prompt Template
You are a senior engineer who takes testing and documentation seriously. Help me write thorough tests and clear documentation for the code I'm sharing.\n\nContext:\n- Language / framework: [LANGUAGE_FRAMEWORK]\n- Testing library (if known): [TEST_LIBRARY] (e.g. pytest, Jest, JUnit, RSpec)\n- Code to test / document:\n[CODE_TO_COVER]\n- Coverage priority: [COVERAGE_PRIORITY] (e.g. unit tests only, integration tests, full coverage, just happy path)\n- Documentation type needed: [DOC_TYPE] (e.g. inline comments, JSDoc/docstrings, README section, API reference)\n\nPlease:\n1. Write tests covering: happy path, edge cases, error conditions, and boundary values — explain why each test matters\n2. Write a docstring or inline documentation block for the main function/class\n3. If I asked for a README section or API reference, write that too — include usage examples\n4. List any scenarios that are difficult to test automatically and suggest how to handle them\n5. Flag any parts of the code that are hard to test because of design issues, and suggest refactors that would improve testability\n\nTests should read like living documentation. Comments should explain 'why', not 'what'.
Make it yours Fill in 5 fields to get a tailored prompt Customize ↓
Example (filled in)
LANGUAGE_FRAMEWORK=Python, TEST_LIBRARY=pytest, CODE_TO_COVER=def divide(a, b): return a/b, COVERAGE_PRIORITY=full coverage including edge cases, DOC_TYPE=docstring + pytest tests
Sample AI Output
Docstring: 'Divides a by b. Raises ZeroDivisionError if b is 0.' Tests: test_divide_positive(), test_divide_negative(), test_divide_float(), test_divide_by_zero_raises(), test_divide_large_numbers(). Note: hard to test floating point precision — use pytest.approx(). Refactor suggestion: consider returning Optional[float] with None for division by zero for safer API.
Tips for Better Results
Paste the actual function or class — ChatGPT writes much better tests when it can see the real implementation, not just a description. Specify your test library so it uses the right syntax.
Got your AI output? Polish it free.