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: community6metadata:7 source: https://skillmd.com/skills/mayurrathi/tdd-workflows-tdd-red8---910Write comprehensive failing tests following TDD red phase principles.1112[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]1314## Use this skill when1516- Starting the TDD red phase for new behavior17- You need failing tests that capture expected behavior18- You want edge case coverage before implementation1920## Do not use this skill when2122- You are in the green or refactor phase23- You only need performance benchmarks24- Tests must run against production systems2526## Instructions27281. Identify behaviors, constraints, and edge cases.292. Generate failing tests that define expected outcomes.303. Ensure failures are due to missing behavior, not setup errors.314. Document how to run tests and verify failures.3233## Safety3435- Keep test data isolated and avoid production environments.36- Avoid flaky external dependencies in the red phase.3738## Role3940Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".4142## Prompt Template4344"Generate comprehensive FAILING tests for: $ARGUMENTS4546## Core Requirements47481. **Test Structure**49 - Framework-appropriate setup (Jest/pytest/JUnit/Go/RSpec)50 - Arrange-Act-Assert pattern51 - should_X_when_Y naming convention52 - Isolated fixtures with no interdependencies53542. **Behavior Coverage**55 - Happy path scenarios56 - Edge cases (empty, null, boundary values)57 - Error handling and exceptions58 - Concurrent access (if applicable)59603. **Failure Verification**61 - Tests MUST fail when run62 - Failures for RIGHT reasons (not syntax/import errors)63 - Meaningful diagnostic error messages64 - No cascading failures65664. **Test Categories**67 - Unit: Isolated component behavior68 - Integration: Component interaction69 - Contract: API/interface contracts70 - Property: Mathematical invariants7172## Framework Patterns7374**JavaScript/TypeScript (Jest/Vitest)**75- Mock dependencies with `vi.fn()` or `jest.fn()`76- Use `@testing-library` for React components77- Property tests with `fast-check`7879**Python (pytest)**80- Fixtures with appropriate scopes81- Parametrize for multiple test cases82- Hypothesis for property-based tests8384**Go**85- Table-driven tests with subtests86- `t.Parallel()` for parallel execution87- Use `testify/assert` for cleaner assertions8889**Ruby (RSpec)**90- `let` for lazy loading, `let!` for eager91- Contexts for different scenarios92- Shared examples for common behavior9394## Quality Checklist9596- Readable test names documenting intent97- One behavior per test98- No implementation leakage99- Meaningful test data (not 'foo'/'bar')100- Tests serve as living documentation101102## Anti-Patterns to Avoid103104- Tests passing immediately105- Testing implementation vs behavior106- Complex setup code107- Multiple responsibilities per test108- Brittle tests tied to specifics109110## Edge Case Categories111112- **Null/Empty**: undefined, null, empty string/array/object113- **Boundaries**: min/max values, single element, capacity limits114- **Special Cases**: Unicode, whitespace, special characters115- **State**: Invalid transitions, concurrent modifications116- **Errors**: Network failures, timeouts, permissions117118## Output Requirements119120- Complete test files with imports121- Documentation of test purpose122- Commands to run and verify failures123- Metrics: test count, coverage areas124- Next steps for green phase"125126## Validation127128After generation:1291. Run tests - confirm they fail1302. Verify helpful failure messages1313. Check test independence1324. Ensure comprehensive coverage133134## Example (Minimal)135136```typescript137// auth.service.test.ts138describe('AuthService', () => {139 let authService: AuthService;140 let mockUserRepo: jest.Mocked<UserRepository>;141142 beforeEach(() => {143 mockUserRepo = { findByEmail: jest.fn() } as any;144 authService = new AuthService(mockUserRepo);145 });146147 it('should_return_token_when_valid_credentials', async () => {148 const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };149 mockUserRepo.findByEmail.mockResolvedValue(user);150151 const result = await authService.authenticate('test@example.com', 'pass');152153 expect(result.success).toBe(true);154 expect(result.token).toBeDefined();155 });156157 it('should_fail_when_user_not_found', async () => {158 mockUserRepo.findByEmail.mockResolvedValue(null);159160 const result = await authService.authenticate('none@example.com', 'pass');161162 expect(result.success).toBe(false);163 expect(result.error).toBe('INVALID_CREDENTIALS');164 });165});166```167168Test requirements: $ARGUMENTS