Write comprehensive failing tests following TDD red phase principles.
[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]
Use this skill when
- Starting the TDD red phase for new behavior
- You need failing tests that capture expected behavior
- You want edge case coverage before implementation
Do not use this skill when
- You are in the green or refactor phase
- You only need performance benchmarks
- Tests must run against production systems
Instructions
- Identify behaviors, constraints, and edge cases.
- Generate failing tests that define expected outcomes.
- Ensure failures are due to missing behavior, not setup errors.
- Document how to run tests and verify failures.
Safety
- Keep test data isolated and avoid production environments.
- Avoid flaky external dependencies in the red phase.
Role
Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".
Prompt Template
"Generate comprehensive FAILING tests for: $ARGUMENTS
Core Requirements
Test Structure
- Framework-appropriate setup (Jest/pytest/JUnit/Go/RSpec)
- Arrange-Act-Assert pattern
- should_X_when_Y naming convention
- Isolated fixtures with no interdependencies
Behavior Coverage
- Happy path scenarios
- Edge cases (empty, null, boundary values)
- Error handling and exceptions
- Concurrent access (if applicable)
Failure Verification
- Tests MUST fail when run
- Failures for RIGHT reasons (not syntax/import errors)
- Meaningful diagnostic error messages
- No cascading failures
Test Categories
- Unit: Isolated component behavior
- Integration: Component interaction
- Contract: API/interface contracts
- Property: Mathematical invariants
Framework Patterns
JavaScript/TypeScript (Jest/Vitest)
- Mock dependencies with
vi.fn() or jest.fn()
- Use
@testing-library for React components
- Property tests with
fast-check
Python (pytest)
- Fixtures with appropriate scopes
- Parametrize for multiple test cases
- Hypothesis for property-based tests
Go
- Table-driven tests with subtests
t.Parallel() for parallel execution
- Use
testify/assert for cleaner assertions
Ruby (RSpec)
let for lazy loading, let! for eager
- Contexts for different scenarios
- Shared examples for common behavior
Quality Checklist
- Readable test names documenting intent
- One behavior per test
- No implementation leakage
- Meaningful test data (not 'foo'/'bar')
- Tests serve as living documentation
Anti-Patterns to Avoid
- Tests passing immediately
- Testing implementation vs behavior
- Complex setup code
- Multiple responsibilities per test
- Brittle tests tied to specifics
Edge Case Categories
- Null/Empty: undefined, null, empty string/array/object
- Boundaries: min/max values, single element, capacity limits
- Special Cases: Unicode, whitespace, special characters
- State: Invalid transitions, concurrent modifications
- Errors: Network failures, timeouts, permissions
Output Requirements
- Complete test files with imports
- Documentation of test purpose
- Commands to run and verify failures
- Metrics: test count, coverage areas
- Next steps for green phase"
Validation
After generation:
- Run tests - confirm they fail
- Verify helpful failure messages
- Check test independence
- Ensure comprehensive coverage
Example (Minimal)
// auth.service.test.ts
describe('AuthService', () => {
let authService: AuthService;
let mockUserRepo: jest.Mocked<UserRepository>;
beforeEach(() => {
mockUserRepo = { findByEmail: jest.fn() } as any;
authService = new AuthService(mockUserRepo);
});
it('should_return_token_when_valid_credentials', async () => {
const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };
mockUserRepo.findByEmail.mockResolvedValue(user);
const result = await authService.authenticate('test@example.com', 'pass');
expect(result.success).toBe(true);
expect(result.token).toBeDefined();
});
it('should_fail_when_user_not_found', async () => {
mockUserRepo.findByEmail.mockResolvedValue(null);
const result = await authService.authenticate('none@example.com', 'pass');
expect(result.success).toBe(false);
expect(result.error).toBe('INVALID_CREDENTIALS');
});
});
Test requirements: $ARGUMENTS
1---
2name: tdd-workflows-tdd-red
3description: "Generate failing tests for the TDD red phase to define expected behavior and edge cases."
4risk: safe
5source: community
6date_added: "2026-02-27"
7metadata:
8 source: https://skillmd.com/skills/kursku/tdd-workflows-tdd-red
9---
10
11Write comprehensive failing tests following TDD red phase principles.
12
13[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]
14
15## Use this skill when
16
17- Starting the TDD red phase for new behavior
18- You need failing tests that capture expected behavior
19- You want edge case coverage before implementation
20
21## Do not use this skill when
22
23- You are in the green or refactor phase
24- You only need performance benchmarks
25- Tests must run against production systems
26
27## Instructions
28
291. Identify behaviors, constraints, and edge cases.
302. Generate failing tests that define expected outcomes.
313. Ensure failures are due to missing behavior, not setup errors.
324. Document how to run tests and verify failures.
33
34## Safety
35
36- Keep test data isolated and avoid production environments.
37- Avoid flaky external dependencies in the red phase.
38
39## Role
40
41Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".
42
43## Prompt Template
44
45"Generate comprehensive FAILING tests for: $ARGUMENTS
46
47## Core Requirements
48
491. **Test Structure**
50 - Framework-appropriate setup (Jest/pytest/JUnit/Go/RSpec)
51 - Arrange-Act-Assert pattern
52 - should_X_when_Y naming convention
53 - Isolated fixtures with no interdependencies
54
552. **Behavior Coverage**
56 - Happy path scenarios
57 - Edge cases (empty, null, boundary values)
58 - Error handling and exceptions
59 - Concurrent access (if applicable)
60
613. **Failure Verification**
62 - Tests MUST fail when run
63 - Failures for RIGHT reasons (not syntax/import errors)
64 - Meaningful diagnostic error messages
65 - No cascading failures
66
674. **Test Categories**
68 - Unit: Isolated component behavior
69 - Integration: Component interaction
70 - Contract: API/interface contracts
71 - Property: Mathematical invariants
72
73## Framework Patterns
74
75**JavaScript/TypeScript (Jest/Vitest)**
76- Mock dependencies with `vi.fn()` or `jest.fn()`
77- Use `@testing-library` for React components
78- Property tests with `fast-check`
79
80**Python (pytest)**
81- Fixtures with appropriate scopes
82- Parametrize for multiple test cases
83- Hypothesis for property-based tests
84
85**Go**
86- Table-driven tests with subtests
87- `t.Parallel()` for parallel execution
88- Use `testify/assert` for cleaner assertions
89
90**Ruby (RSpec)**
91- `let` for lazy loading, `let!` for eager
92- Contexts for different scenarios
93- Shared examples for common behavior
94
95## Quality Checklist
96
97- Readable test names documenting intent
98- One behavior per test
99- No implementation leakage
100- Meaningful test data (not 'foo'/'bar')
101- Tests serve as living documentation
102
103## Anti-Patterns to Avoid
104
105- Tests passing immediately
106- Testing implementation vs behavior
107- Complex setup code
108- Multiple responsibilities per test
109- Brittle tests tied to specifics
110
111## Edge Case Categories
112
113- **Null/Empty**: undefined, null, empty string/array/object
114- **Boundaries**: min/max values, single element, capacity limits
115- **Special Cases**: Unicode, whitespace, special characters
116- **State**: Invalid transitions, concurrent modifications
117- **Errors**: Network failures, timeouts, permissions
118
119## Output Requirements
120
121- Complete test files with imports
122- Documentation of test purpose
123- Commands to run and verify failures
124- Metrics: test count, coverage areas
125- Next steps for green phase"
126
127## Validation
128
129After generation:
1301. Run tests - confirm they fail
1312. Verify helpful failure messages
1323. Check test independence
1334. Ensure comprehensive coverage
134
135## Example (Minimal)
136
137```typescript
138// auth.service.test.ts
139describe('AuthService', () => {
140 let authService: AuthService;
141 let mockUserRepo: jest.Mocked<UserRepository>;
142
143 beforeEach(() => {
144 mockUserRepo = { findByEmail: jest.fn() } as any;
145 authService = new AuthService(mockUserRepo);
146 });
147
148 it('should_return_token_when_valid_credentials', async () => {
149 const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };
150 mockUserRepo.findByEmail.mockResolvedValue(user);
151
152 const result = await authService.authenticate('test@example.com', 'pass');
153
154 expect(result.success).toBe(true);
155 expect(result.token).toBeDefined();
156 });
157
158 it('should_fail_when_user_not_found', async () => {
159 mockUserRepo.findByEmail.mockResolvedValue(null);
160
161 const result = await authService.authenticate('none@example.com', 'pass');
162
163 expect(result.success).toBe(false);
164 expect(result.error).toBe('INVALID_CREDENTIALS');
165 });
166});
167```
168
169Test requirements: $ARGUMENTS