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-red3description: "Generate failing tests for the TDD red phase to define expected behavior and edge cases."4risk: unknown5source: community6date_added: "2026-02-27"7metadata:8 source: https://skillmd.com/skills/nimoqup046-collab/tdd-workflows-tdd-red9---1011Write comprehensive failing tests following TDD red phase principles.1213[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]1415## Use this skill when1617- Starting the TDD red phase for new behavior18- You need failing tests that capture expected behavior19- You want edge case coverage before implementation2021## Do not use this skill when2223- You are in the green or refactor phase24- You only need performance benchmarks25- Tests must run against production systems2627## Instructions28291. 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.3334## Safety3536- Keep test data isolated and avoid production environments.37- Avoid flaky external dependencies in the red phase.3839## Role4041Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".4243## Prompt Template4445"Generate comprehensive FAILING tests for: $ARGUMENTS4647## Core Requirements48491. **Test Structure**50 - Framework-appropriate setup (Jest/pytest/JUnit/Go/RSpec)51 - Arrange-Act-Assert pattern52 - should_X_when_Y naming convention53 - Isolated fixtures with no interdependencies54552. **Behavior Coverage**56 - Happy path scenarios57 - Edge cases (empty, null, boundary values)58 - Error handling and exceptions59 - Concurrent access (if applicable)60613. **Failure Verification**62 - Tests MUST fail when run63 - Failures for RIGHT reasons (not syntax/import errors)64 - Meaningful diagnostic error messages65 - No cascading failures66674. **Test Categories**68 - Unit: Isolated component behavior69 - Integration: Component interaction70 - Contract: API/interface contracts71 - Property: Mathematical invariants7273## Framework Patterns7475**JavaScript/TypeScript (Jest/Vitest)**76- Mock dependencies with `vi.fn()` or `jest.fn()`77- Use `@testing-library` for React components78- Property tests with `fast-check`7980**Python (pytest)**81- Fixtures with appropriate scopes82- Parametrize for multiple test cases83- Hypothesis for property-based tests8485**Go**86- Table-driven tests with subtests87- `t.Parallel()` for parallel execution88- Use `testify/assert` for cleaner assertions8990**Ruby (RSpec)**91- `let` for lazy loading, `let!` for eager92- Contexts for different scenarios93- Shared examples for common behavior9495## Quality Checklist9697- Readable test names documenting intent98- One behavior per test99- No implementation leakage100- Meaningful test data (not 'foo'/'bar')101- Tests serve as living documentation102103## Anti-Patterns to Avoid104105- Tests passing immediately106- Testing implementation vs behavior107- Complex setup code108- Multiple responsibilities per test109- Brittle tests tied to specifics110111## Edge Case Categories112113- **Null/Empty**: undefined, null, empty string/array/object114- **Boundaries**: min/max values, single element, capacity limits115- **Special Cases**: Unicode, whitespace, special characters116- **State**: Invalid transitions, concurrent modifications117- **Errors**: Network failures, timeouts, permissions118119## Output Requirements120121- Complete test files with imports122- Documentation of test purpose123- Commands to run and verify failures124- Metrics: test count, coverage areas125- Next steps for green phase"126127## Validation128129After generation:1301. Run tests - confirm they fail1312. Verify helpful failure messages1323. Check test independence1334. Ensure comprehensive coverage134135## Example (Minimal)136137```typescript138// auth.service.test.ts139describe('AuthService', () => {140 let authService: AuthService;141 let mockUserRepo: jest.Mocked<UserRepository>;142143 beforeEach(() => {144 mockUserRepo = { findByEmail: jest.fn() } as any;145 authService = new AuthService(mockUserRepo);146 });147148 it('should_return_token_when_valid_credentials', async () => {149 const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };150 mockUserRepo.findByEmail.mockResolvedValue(user);151152 const result = await authService.authenticate('test@example.com', 'pass');153154 expect(result.success).toBe(true);155 expect(result.token).toBeDefined();156 });157158 it('should_fail_when_user_not_found', async () => {159 mockUserRepo.findByEmail.mockResolvedValue(null);160161 const result = await authService.authenticate('none@example.com', 'pass');162163 expect(result.success).toBe(false);164 expect(result.error).toBe('INVALID_CREDENTIALS');165 });166});167```168169Test requirements: $ARGUMENTS