name: tdd-workflows-tdd-red
description: Generate failing tests for the TDD red phase to define expected behavior and edge cases.
tags: [testing, workflows]
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-23description: <!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT -->4---5<!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT -->6---7name: tdd-workflows-tdd-red8description: Generate failing tests for the TDD red phase to define expected behavior and edge cases.9tags: [testing, workflows]10---1112Write comprehensive failing tests following TDD red phase principles.1314[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]1516## Use this skill when1718- Starting the TDD red phase for new behavior19- You need failing tests that capture expected behavior20- You want edge case coverage before implementation2122## Do not use this skill when2324- You are in the green or refactor phase25- You only need performance benchmarks26- Tests must run against production systems2728## Instructions29301. Identify behaviors, constraints, and edge cases.312. Generate failing tests that define expected outcomes.323. Ensure failures are due to missing behavior, not setup errors.334. Document how to run tests and verify failures.3435## Safety3637- Keep test data isolated and avoid production environments.38- Avoid flaky external dependencies in the red phase.3940## Role4142Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".4344## Prompt Template4546"Generate comprehensive FAILING tests for: $ARGUMENTS4748## Core Requirements49501. **Test Structure**51 - Framework-appropriate setup (Jest/pytest/JUnit/Go/RSpec)52 - Arrange-Act-Assert pattern53 - should_X_when_Y naming convention54 - Isolated fixtures with no interdependencies55562. **Behavior Coverage**57 - Happy path scenarios58 - Edge cases (empty, null, boundary values)59 - Error handling and exceptions60 - Concurrent access (if applicable)61623. **Failure Verification**63 - Tests MUST fail when run64 - Failures for RIGHT reasons (not syntax/import errors)65 - Meaningful diagnostic error messages66 - No cascading failures67684. **Test Categories**69 - Unit: Isolated component behavior70 - Integration: Component interaction71 - Contract: API/interface contracts72 - Property: Mathematical invariants7374## Framework Patterns7576**JavaScript/TypeScript (Jest/Vitest)**77- Mock dependencies with `vi.fn()` or `jest.fn()`78- Use `@testing-library` for React components79- Property tests with `fast-check`8081**Python (pytest)**82- Fixtures with appropriate scopes83- Parametrize for multiple test cases84- Hypothesis for property-based tests8586**Go**87- Table-driven tests with subtests88- `t.Parallel()` for parallel execution89- Use `testify/assert` for cleaner assertions9091**Ruby (RSpec)**92- `let` for lazy loading, `let!` for eager93- Contexts for different scenarios94- Shared examples for common behavior9596## Quality Checklist9798- Readable test names documenting intent99- One behavior per test100- No implementation leakage101- Meaningful test data (not 'foo'/'bar')102- Tests serve as living documentation103104## Anti-Patterns to Avoid105106- Tests passing immediately107- Testing implementation vs behavior108- Complex setup code109- Multiple responsibilities per test110- Brittle tests tied to specifics111112## Edge Case Categories113114- **Null/Empty**: undefined, null, empty string/array/object115- **Boundaries**: min/max values, single element, capacity limits116- **Special Cases**: Unicode, whitespace, special characters117- **State**: Invalid transitions, concurrent modifications118- **Errors**: Network failures, timeouts, permissions119120## Output Requirements121122- Complete test files with imports123- Documentation of test purpose124- Commands to run and verify failures125- Metrics: test count, coverage areas126- Next steps for green phase"127128## Validation129130After generation:1311. Run tests - confirm they fail1322. Verify helpful failure messages1333. Check test independence1344. Ensure comprehensive coverage135136## Example (Minimal)137138```typescript139// auth.service.test.ts140describe('AuthService', () => {141 let authService: AuthService;142 let mockUserRepo: jest.Mocked<UserRepository>;143144 beforeEach(() => {145 mockUserRepo = { findByEmail: jest.fn() } as any;146 authService = new AuthService(mockUserRepo);147 });148149 it('should_return_token_when_valid_credentials', async () => {150 const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };151 mockUserRepo.findByEmail.mockResolvedValue(user);152153 const result = await authService.authenticate('test@example.com', 'pass');154155 expect(result.success).toBe(true);156 expect(result.token).toBeDefined();157 });158159 it('should_fail_when_user_not_found', async () => {160 mockUserRepo.findByEmail.mockResolvedValue(null);161162 const result = await authService.authenticate('none@example.com', 'pass');163164 expect(result.success).toBe(false);165 expect(result.error).toBe('INVALID_CREDENTIALS');166 });167});168```169170Test requirements: $ARGUMENTS171172<!-- Source: .faos/custom/skills/testing/tdd-workflows-tdd-red/SKILL.md -->