Home › Testing › Generate tests prompt file (Copilot)

Generate tests prompt file (Copilot)

A Copilot prompt file (/generate-tests) that writes focused unit tests for the selected code using the repo framework.

GitHub CopilotTesting

How to use

Save this as .github/prompts/generate-tests.prompt.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.github/prompts/generate-tests.prompt.mdDownload  
---
description: Generate focused unit tests for the selected code or file
agent: agent
argument-hint: file or function to test
---

Write unit tests for ${selection} (if nothing is selected, use ${file}).

1. Detect the test framework, helpers, and file naming used in this repo by reading an existing test near the target. Follow them exactly.
2. List the behaviors to cover before writing code: the happy path, edge cases (empty, null, boundaries, large inputs), and error paths. Show this list.
3. Write one test per behavior with a descriptive name. Use parametrized/table tests for input variations.
4. Mock only external boundaries (network, clock, filesystem, randomness). Don't mock the unit under test or its simple collaborators.
5. Run the new test file and fix failures in the tests. If a failure reveals a real bug in the code, don't change the code; report the bug with the failing test.
6. Finish with: the file created, the behaviors covered, the command to run them, and any behaviors you couldn't test and why.

Don't modify production code or existing tests in this task.

More: all Testing rules · all GitHub Copilot rules

Related rules

Cypress end-to-end testing AGENTS.md

AGENTS.md for Cypress 15 E2E and component tests: selectors, cy.intercept, sessions, and flake-free waits.

AGENTS.mdTesting

Jest testing rules

Cursor rules for Jest 30 test suites in TypeScript: structure, mocking boundaries, timers, and async tests.

CursorTesting

Playwright end-to-end testing rules

Cursor rules for Playwright Test (TypeScript): resilient locators, web-first assertions, fixtures, and no flaky waits.

CursorTesting

pytest testing CLAUDE.md

CLAUDE.md for Python test suites with pytest 8: fixtures, parametrize, mocking boundaries, and coverage.

Claude Code (CLAUDE.md)Testing

Test runner subagent (Claude Code)

A Claude Code subagent that runs the right tests for a change, diagnoses failures, and proposes minimal fixes.

Claude Code (CLAUDE.md)Testing

Testing .claude/rules file

A path-scoped Claude Code rules file that loads only for test files: structure, determinism, and never weakening tests.

Claude Code (CLAUDE.md)Testing

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.