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
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
1---2name: tdd-workflows-tdd-red3description: Generate failing tests for the TDD red phase to define expected behavior and edge cases.4license: MIT5---67Write comprehensive failing tests following TDD red phase principles.89[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]1011## Use this skill when1213- Starting the TDD red phase for new behavior14- You need failing tests that capture expected behavior15- You want edge case coverage before implementation1617## Do not use this skill when1819- You are in the green or refactor phase20- You only need performance benchmarks21- Tests must run against production systems2223## Instructions24251. Identify behaviors, constraints, and edge cases.262. Generate failing tests that define expected outcomes.273. Ensure failures are due to missing behavior, not setup errors.284. Document how to run tests and verify failures.2930## Safety3132- Keep test data isolated and avoid production environments.33- Avoid flaky external dependencies in the red phase.3435## Role3637Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".3839## Prompt Template4041"Generate comprehensive FAILING tests for: $ARGUMENTS4243## Core Requirements44451. **Test Structure**46 - Framework-appropriate setup (Jest/pytest/JUnit/Go/RSpec)47 - Arrange-Act-Assert pattern48 - should_X_when_Y naming convention49 - Isolated fixtures with no interdependencies50512. **Behavior Coverage**52 - Happy path scenarios53 - Edge cases (empty, null, boundary values)54 - Error handling and exceptions55 - Concurrent access (if applicable)56573. **Failure Verification**58 - Tests MUST fail when run59 - Failures for RIGHT reasons (not syntax/import errors)60 - Meaningful diagnostic error messages61 - No cascading failures62634. **Test Categories**64 - Unit: Isolated component behavior65 - Integration: Component interaction66 - Contract: API/interface contracts67 - Property: Mathematical invariants6869## Framework Patterns7071**JavaScript/TypeScript (Jest/Vitest)**72- Mock dependencies with `vi.fn()` or `jest.fn()`73- Use `@testing-library` for React components74- Property tests with `fast-check`7576**Python (pytest)**77- Fixtures with appropriate scopes78- Parametrize for multiple test cases79- Hypothesis for property-based tests8081**Go**82- Table-driven tests with subtests83- `t.Parallel()` for parallel execution84- Use `testify/assert` for cleaner assertions8586**Ruby (RSpec)**87- `let` for lazy loading, `let!` for eager88- Contexts for different scenarios89- Shared examples for common behavior9091## Quality Checklist9293- Readable test names documenting intent94- One behavior per test95- No implementation leakage96- Meaningful test data (not 'foo'/'bar')97- Tests serve as living documentation9899## Anti-Patterns to Avoid100101- Tests passing immediately102- Testing implementation vs behavior103- Complex setup code104- Multiple responsibilities per test105- Brittle tests tied to specifics106107## Edge Case Categories108109- **Null/Empty**: undefined, null, empty string/array/object110- **Boundaries**: min/max values, single element, capacity limits111- **Special Cases**: Unicode, whitespace, special characters112- **State**: Invalid transitions, concurrent modifications113- **Errors**: Network failures, timeouts, permissions114115## Output Requirements116117- Complete test files with imports118- Documentation of test purpose119- Commands to run and verify failures120- Metrics: test count, coverage areas121- Next steps for green phase"122123## Validation124125After generation:1261. Run tests - confirm they fail1272. Verify helpful failure messages1283. Check test independence1294. Ensure comprehensive coverage130131## Example (Minimal)132133```typescript134// auth.service.test.ts135describe('AuthService', () => {136 let authService: AuthService;137 let mockUserRepo: jest.Mocked<UserRepository>;138139 beforeEach(() => {140 mockUserRepo = { findByEmail: jest.fn() } as any;141 authService = new AuthService(mockUserRepo);142 });143144 it('should_return_token_when_valid_credentials', async () => {145 const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };146 mockUserRepo.findByEmail.mockResolvedValue(user);147148 const result = await authService.authenticate('test@example.com', 'pass');149150 expect(result.success).toBe(true);151 expect(result.token).toBeDefined();152 });153154 it('should_fail_when_user_not_found', async () => {155 mockUserRepo.findByEmail.mockResolvedValue(null);156157 const result = await authService.authenticate('none@example.com', 'pass');158159 expect(result.success).toBe(false);160 expect(result.error).toBe('INVALID_CREDENTIALS');161 });162});163```164165Test requirements: $ARGUMENTS166167## Limitations168- Use this skill only when the task clearly matches the scope described above.169- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.170- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.