A skill for generating comprehensive test suites with Copilot including unit tests, integration tests, and edge case coverage.
## Copilot Test Generation Skill
### Overview
Use Copilot to generate thorough test suites by providing the right context and using effective prompting patterns.
### Method 1: Inline Test Generation
Write a test file and let Copilot complete test cases:
```typescript
import { calculateDiscount } from './pricing';
describe('calculateDiscount', () => {
it('should apply percentage discount to subtotal', () => {
// Copilot generates the test body
});
it('should not allow discount to exceed subtotal', () => {
// Copilot generates boundary test
});
it('should return 0 discount for expired coupon', () => {
// Copilot generates error case test
});
```
### Method 2: Chat-Based Generation
Use Copilot Chat with the `/tests` command:
```
/tests Generate comprehensive tests for the UserService class
including: createUser, updateUser, deleteUser, getUserById.
Cover happy path, validation errors, not found,
and duplicate email scenarios.
```
### Method 3: Test from Specification
Describe behavior and let Copilot generate both tests and implementation:
```
Write tests for a password strength validator that:
- Returns 'weak' for passwords under 8 characters
- Returns 'medium' for 8+ chars with letters and numbers
- Returns 'strong' for 12+ chars with letters, numbers, and symbols
- Returns 'very_strong' for 16+ chars with all character types
- Rejects passwords containing the username
- Rejects common passwords from a blocklist
```
### Method 4: Property-Based Testing
Ask Copilot to generate property-based tests:
```
Generate property-based tests for the sortUsers function:
- Output length equals input length
- Output is sorted according to the specified field
- All original elements are present in the output
- Sorting is stable (equal elements maintain relative order)
```
### Test Quality Checklist
- Each test tests one behavior (single assertion concept)
- Test names describe the expected behavior clearly
- Arrange-Act-Assert structure in every test
- No test depends on another test's execution
- Mocks are reset between tests
- Both positive and negative cases are covered
- Edge cases: empty, null, boundary values, large inputs
### Coverage Gap Analysis
Ask Copilot to find missing tests:
```
@workspace Analyze the test coverage for src/services/.
Identify functions and code paths that lack test coverage.
Suggest specific test cases for uncovered branches.
```
### Generating Test Data
Use Copilot to create realistic test fixtures:
```
Generate a test fixture factory for User objects with:
- Realistic fake data (names, emails, dates)
- Override capability for specific fields
- Related objects (user with posts, user with orders)
- Edge case variants (long name, special characters, max values)
```Free to copy and use. Compatible with GitHub Copilot, GPT-5.
Use these patterns when generating tests with Copilot. Start with Method 1 for quick inline tests, use Method 2 via Chat for full test suites.
Initial release
gh copilot skill install copilot-test-generation-automation-skillSign in and download this prompt to leave a review.