home / skills / proffesor-for-testing / agentic-qe / qe-test-generation

qe-test-generation skill

/v3/assets/skills/qe-test-generation

This skill automates AI-powered test generation from code analysis and patterns to improve coverage across frameworks.

npx playbooks add skill proffesor-for-testing/agentic-qe --skill qe-test-generation

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.3 KB
---
name: "QE Test Generation"
description: "AI-powered test generation using pattern recognition, code analysis, and intelligent test synthesis for comprehensive test coverage."
---

# QE Test Generation

## Purpose

Guide the use of v3's AI-powered test generation capabilities including pattern-based test synthesis, multi-framework support, and intelligent test case derivation from code analysis.

## Activation

- When generating tests for new code
- When improving test coverage
- When migrating tests between frameworks
- When applying TDD patterns
- When generating edge case tests

## Quick Start

```bash
# Generate unit tests for a file
aqe test generate --file src/services/UserService.ts --framework jest

# Generate tests with coverage target
aqe test generate --scope src/api/ --coverage 90 --type unit

# Generate integration tests
aqe test generate --file src/controllers/AuthController.ts --type integration

# Generate from patterns
aqe test generate --pattern repository --target src/repositories/
```

## Agent Workflow

```typescript
// Spawn test generation agents
Task("Generate unit tests", `
  Analyze src/services/PaymentService.ts and generate comprehensive Jest tests.
  Include:
  - Happy path tests for all public methods
  - Edge cases and boundary conditions
  - Error handling scenarios
  - Mock external dependencies
  Output to tests/unit/services/PaymentService.test.ts
`, "qe-test-generator")

// Pattern-based generation
Task("Apply test patterns", `
  Scan src/repositories/ and apply repository test pattern:
  - CRUD operation tests
  - Query builder tests
  - Transaction tests
  - Connection error handling
`, "qe-pattern-matcher")
```

## Test Generation Strategies

### 1. Code Analysis Based

```typescript
await testGenerator.analyzeAndGenerate({
  source: 'src/services/OrderService.ts',
  analysis: {
    methods: true,
    branches: true,
    dependencies: true,
    errorPaths: true
  },
  output: {
    framework: 'jest',
    style: 'describe-it',
    assertions: 'expect'
  }
});
```

### 2. Pattern-Based Generation

```typescript
await testGenerator.applyPattern({
  pattern: 'service-layer',
  targets: ['src/services/*.ts'],
  customizations: {
    mockStrategy: 'jest.mock',
    asyncHandling: 'async-await',
    errorAssertion: 'toThrow'
  }
});
```

### 3. Coverage-Driven Generation

```typescript
await testGenerator.fillCoverageGaps({
  coverageReport: 'coverage/lcov.info',
  targetCoverage: 90,
  prioritize: ['uncovered-branches', 'error-paths'],
  maxTests: 50
});
```

## Framework Support

| Framework | Unit | Integration | E2E | Mocking |
|-----------|------|-------------|-----|---------|
| Jest | ✅ | ✅ | ⚠️ | jest.mock |
| Vitest | ✅ | ✅ | ⚠️ | vi.mock |
| Mocha | ✅ | ✅ | ❌ | sinon |
| Pytest | ✅ | ✅ | ❌ | pytest-mock |
| JUnit | ✅ | ✅ | ❌ | Mockito |

## Test Quality Checks

```yaml
quality_checks:
  assertions:
    minimum_per_test: 1
    meaningful: true

  isolation:
    no_shared_state: true
    proper_setup_teardown: true

  naming:
    descriptive: true
    follows_convention: true

  coverage:
    branches: 80
    statements: 85
```

## Coordination

**Primary Agents**: qe-test-generator, qe-pattern-matcher, qe-test-architect
**Coordinator**: qe-test-generation-coordinator
**Related Skills**: qe-coverage-analysis, qe-test-execution

Overview

This skill provides AI-powered test generation using pattern recognition, code analysis, and intelligent test synthesis to produce comprehensive test suites across multiple frameworks. It automates unit, integration, and targeted edge-case tests while supporting coverage-driven and pattern-based strategies. The goal is faster, higher-quality test creation with configurable output and framework compatibility.

How this skill works

The system analyzes source code to detect methods, branches, dependencies, and error paths, then synthesizes tests that cover happy paths, edge cases, and failure scenarios. It applies reusable test patterns (service, repository, controller) and can prioritize uncovered branches from coverage reports to automatically fill gaps. Outputs are generated in the chosen framework style (Jest, Vitest, Mocha, Pytest, JUnit) with mocking strategies and configurable assertions.

When to use it

  • When generating tests for new or recently changed code to accelerate coverage.
  • When improving test coverage or filling coverage report gaps (coverage-driven generation).
  • When migrating tests between frameworks or standardizing test style.
  • When applying TDD patterns to bootstrap test suites from requirements.
  • When creating edge-case, error-path, and boundary-condition tests.

Best practices

  • Start with code analysis generation, then apply pattern-based templates for consistent structure.
  • Provide coverage reports and a target coverage percentage to focus generation on uncovered branches.
  • Customize mock strategies and async handling to match project conventions (e.g., jest.mock or vi.mock).
  • Limit max generated tests per run and review high-risk error-path tests manually.
  • Enforce quality checks: meaningful assertions, isolation, proper setup/teardown, and descriptive names.

Example use cases

  • Generate Jest unit tests for a service file with happy path, edge cases, and mocked dependencies.
  • Scan repository folder and apply CRUD and transaction patterns to create repository tests.
  • Fill coverage gaps by prioritizing uncovered branches and error paths to reach a coverage target.
  • Migrate an existing Mocha suite to Vitest-style tests with automated pattern transformations.
  • Create integration tests for controllers that assert request handling and error responses.

FAQ

Which frameworks are supported?

Supports Jest, Vitest, Mocha, Pytest, and JUnit with framework-specific mocking strategies.

Can it prioritize coverage targets?

Yes—provide a coverage report and target percentage; the generator will prioritize uncovered branches and error paths.