Skills

Test Generation

Use when the user asks for tests, mentions TDD, or when new code has been written and...

Install

npx skills add darrenhinde/OpenAgentsControl --skill test-generation -g -a claude-code -y
Category
Testing
Updated
9d ago
License
MIT
Context cost
Lightabout 1,114 tokens
Runs scripts
No, instructions only

What it does

Use when the user asks for tests, mentions TDD, or when new code has been written and needs test coverage.

Test Generation

Overview

Generate comprehensive tests following TDD principles and project testing standards. Runs in isolated test-engineer context with pre-loaded testing conventions.

Announce at start: "I'm using the test-generation skill to create tests for [feature/component]."

The Process

Step 1: Specify Test Requirements

Provide clear requirements to test-engineer:

/test-generation

Feature: JWT token validation middleware

Behaviors:
1. Valid token → allow request
2. Expired token → reject with 401
3. Invalid signature → reject with 401
4. Missing token → reject with 401

Coverage: All critical paths

Testing Standards (pre-loaded):
- Framework: vitest
- Mocks: vi.mock()
- Structure: AAA pattern

Step 2: Review Test Plan

Test-engineer proposes a test plan:

## Test Plan

Behaviors:
1. Valid token
   - ✅ Positive: Allow request with valid JWT
   - ❌ Negative: Reject malformed JWT
2. Expired token
   - ✅ Positive: Normal token works
   - ❌ Negative: Expired token rejected with 401

Mocking Strategy:
- JWT verification: Mock with vi.mock()
- Request/Response: Use test doubles

Coverage Target: 95% line coverage, all critical paths

IMPORTANT: Review and approve before implementation proceeds.

Step 3: Implement Tests

Test-engineer implements following AAA pattern (Arrange-Act-Assert):

describe('JWT Middleware', () => {
  it('allows request with valid token', () => {
    // Arrange
    const req = mockRequest({ headers: { authorization: 'Bearer valid.jwt.token' } });
    
    // Act
    const result = jwtMiddleware(req);
    
    // Assert
    expect(result.authorized).toBe(true);
  });
});

Step 4: Run Self-Review

Test-engineer verifies:

  • ✅ Positive AND negative tests for each behavior
  • ✅ AAA pattern followed
  • ✅ All external dependencies mocked
  • ✅ Tests are deterministic (no flakiness)
  • ✅ Standards compliance

Step 5: Run Tests

Read the whole SKILL.md on GitHub

More in Testing