Generate failing tests for the TDD red phase to define expected behavior and edge cases.
Add this skill
npx mdskills install sickn33/tdd-workflows-tdd-redComprehensive TDD red-phase skill with excellent structure, framework coverage, and actionable guidance
1---2name: tdd-workflows-tdd-red3description: Generate failing tests for the TDD red phase to define expected behavior and edge cases.4---56Write comprehensive failing tests following TDD red phase principles.78[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]910## Use this skill when1112- Starting the TDD red phase for new behavior13- You need failing tests that capture expected behavior14- You want edge case coverage before implementation1516## Do not use this skill when1718- You are in the green or refactor phase19- You only need performance benchmarks20- Tests must run against production systems2122## Instructions23241. Identify behaviors, constraints, and edge cases.252. Generate failing tests that define expected outcomes.263. Ensure failures are due to missing behavior, not setup errors.274. Document how to run tests and verify failures.2829## Safety3031- Keep test data isolated and avoid production environments.32- Avoid flaky external dependencies in the red phase.3334## Role3536Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".3738## Prompt Template3940"Generate comprehensive FAILING tests for: $ARGUMENTS4142## Core Requirements43441. **Test Structure**45 - Framework-appropriate setup (Jest/pytest/JUnit/Go/RSpec)46 - Arrange-Act-Assert pattern47 - should_X_when_Y naming convention48 - Isolated fixtures with no interdependencies49502. **Behavior Coverage**51 - Happy path scenarios52 - Edge cases (empty, null, boundary values)53 - Error handling and exceptions54 - Concurrent access (if applicable)55563. **Failure Verification**57 - Tests MUST fail when run58 - Failures for RIGHT reasons (not syntax/import errors)59 - Meaningful diagnostic error messages60 - No cascading failures61624. **Test Categories**63 - Unit: Isolated component behavior64 - Integration: Component interaction65 - Contract: API/interface contracts66 - Property: Mathematical invariants6768## Framework Patterns6970**JavaScript/TypeScript (Jest/Vitest)**71- Mock dependencies with `vi.fn()` or `jest.fn()`72- Use `@testing-library` for React components73- Property tests with `fast-check`7475**Python (pytest)**76- Fixtures with appropriate scopes77- Parametrize for multiple test cases78- Hypothesis for property-based tests7980**Go**81- Table-driven tests with subtests82- `t.Parallel()` for parallel execution83- Use `testify/assert` for cleaner assertions8485**Ruby (RSpec)**86- `let` for lazy loading, `let!` for eager87- Contexts for different scenarios88- Shared examples for common behavior8990## Quality Checklist9192- Readable test names documenting intent93- One behavior per test94- No implementation leakage95- Meaningful test data (not 'foo'/'bar')96- Tests serve as living documentation9798## Anti-Patterns to Avoid99100- Tests passing immediately101- Testing implementation vs behavior102- Complex setup code103- Multiple responsibilities per test104- Brittle tests tied to specifics105106## Edge Case Categories107108- **Null/Empty**: undefined, null, empty string/array/object109- **Boundaries**: min/max values, single element, capacity limits110- **Special Cases**: Unicode, whitespace, special characters111- **State**: Invalid transitions, concurrent modifications112- **Errors**: Network failures, timeouts, permissions113114## Output Requirements115116- Complete test files with imports117- Documentation of test purpose118- Commands to run and verify failures119- Metrics: test count, coverage areas120- Next steps for green phase"121122## Validation123124After generation:1251. Run tests - confirm they fail1262. Verify helpful failure messages1273. Check test independence1284. Ensure comprehensive coverage129130## Example (Minimal)131132```typescript133// auth.service.test.ts134describe('AuthService', () => {135 let authService: AuthService;136 let mockUserRepo: jest.Mocked<UserRepository>;137138 beforeEach(() => {139 mockUserRepo = { findByEmail: jest.fn() } as any;140 authService = new AuthService(mockUserRepo);141 });142143 it('should_return_token_when_valid_credentials', async () => {144 const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };145 mockUserRepo.findByEmail.mockResolvedValue(user);146147 const result = await authService.authenticate('test@example.com', 'pass');148149 expect(result.success).toBe(true);150 expect(result.token).toBeDefined();151 });152153 it('should_fail_when_user_not_found', async () => {154 mockUserRepo.findByEmail.mockResolvedValue(null);155156 const result = await authService.authenticate('none@example.com', 'pass');157158 expect(result.success).toBe(false);159 expect(result.error).toBe('INVALID_CREDENTIALS');160 });161});162```163164Test requirements: $ARGUMENTS165
Full transparency — inspect the skill content before installing.