test-generation
Master skill for intelligent test case generation. Identifies technology stack and delegates to specialized testing sub-skills for creating high-quality integration and API tests.
Best use case
test-generation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Master skill for intelligent test case generation. Identifies technology stack and delegates to specialized testing sub-skills for creating high-quality integration and API tests.
Teams using test-generation should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/test-generation/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How test-generation Compares
| Feature / Agent | test-generation | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Master skill for intelligent test case generation. Identifies technology stack and delegates to specialized testing sub-skills for creating high-quality integration and API tests.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Test Generation Framework
## Instructions
You are the entry point for test case generation and quality assurance. Your goal is to **Identify** the technology stack, **Prioritize** testable components, **Generate** comprehensive tests, and **Document** the testing strategy.
## Core Test Generation Process
### Phase 1: Discovery & Analysis
1. **Technology Stack Detection**: Identify languages, frameworks, and testing tools
2. **Component Mapping**: Enumerate all testable endpoints (APIs, services, workflows)
3. **Dependency Review**: Check existing test frameworks and libraries
4. **Coverage Analysis**: Assess current test coverage if tests exist
### Phase 2: Test Scope Prioritization
#### A. Components to ALWAYS Test
- **API Endpoints**: All HTTP routes (GET, POST, PUT, PATCH, DELETE)
- **Service Layer Functions**: Business logic orchestration and data processing
- **Main Execution Functions**: Functions that call multiple sub-functions
- **Database Operations**: CRUD operations, queries, transactions
- **Authentication & Authorization**: Login flows, token validation, permissions
- **Integration Points**: External APIs, message queues, webhooks
- **Critical Workflows**: Payment processing, order fulfillment, user registration
#### B. Components to AVOID Testing
- **Simple Utility Functions**: String formatters, basic validators (unless complex)
- **Framework Generated Code**: ORM models, auto-generated getters/setters
- **Third-Party Libraries**: Already tested by maintainers
- **Pure Configuration**: JSON/YAML without logic
### Phase 3: Test Type Selection
#### A. Integration Tests (Primary Focus - 70%)
**Concept**: Test how components work together in realistic scenarios.
**Action**:
1. **API Integration**: Test endpoints with database interactions
2. **Service Integration**: Test services with real/mocked external dependencies
3. **Database Integration**: Use test containers or in-memory databases
4. **End-to-End Workflows**: Multi-step business processes
#### B. Unit Tests (Secondary Focus - 20%)
**Concept**: Test isolated, complex business logic only.
**Action**:
1. **Complex Algorithms**: Functions with intricate logic and edge cases
2. **Business Rules**: State machines, validation engines
3. **Calculations**: Financial calculations, data transformations
#### C. Contract Tests (10%)
**Concept**: Ensure API stability and compatibility.
**Action**:
1. **Schema Validation**: Request/response structure verification
2. **API Versioning**: Backward compatibility checks
3. **Integration Contracts**: External API mock validation
### Phase 4: Test Generation
#### Test Structure Standards
All generated tests must follow the **AAA (Arrange-Act-Assert)** pattern:
```
describe('Component/Function Name', () => {
it('should [expected behavior] when [condition]', () => {
// Arrange: Set up test data and dependencies
const testData = createTestData();
const mockDependency = mockService();
// Act: Execute the function under test
const result = functionUnderTest(testData);
// Assert: Verify expected outcomes
expect(result).toMatchExpectedValue();
expect(mockDependency).toHaveBeenCalledWith(expectedArgs);
});
});
```
#### Coverage Requirements
For each testable component, generate tests that cover:
1. **Happy Path**: Normal, expected flow
2. **Edge Cases**: Boundary values, empty inputs, null handling
3. **Error Scenarios**: Invalid inputs, network failures, timeout handling
4. **Security Cases**: Authentication failures, authorization violations, injection attempts
#### Test Data Management
1. **Use Factory Functions**: Generate realistic test data programmatically
2. **Create Fixtures**: Define reusable test datasets
3. **Avoid Hardcoding**: Use constants and data generators
4. **Realistic Data**: Mirror production data patterns
### Phase 5: Documentation Generation
#### Test Report Structure
Generate comprehensive test documentation in `test-reports/` folder:
```
test-reports/
├── index.md # Test coverage summary
├── test-plan.md # Testing strategy and scope
├── integration-tests/
│ ├── api-tests.md # API endpoint test docs
│ ├── service-tests.md # Service layer test docs
│ └── workflow-tests.md # E2E workflow test docs
├── coverage/
│ ├── coverage-summary.md # Code coverage metrics
│ └── gaps-analysis.md # Coverage gaps
└── execution/
├── setup-guide.md # How to run tests
└── ci-integration.md # CI/CD pipeline guide
```
## Technology-Specific Testing Patterns
### Node.js / JavaScript Testing
**Focus Areas**: API testing, async operations, service integration
**Key Frameworks**: Jest, Vitest, Mocha + Chai, Supertest
**Patterns**:
- API endpoint testing with Supertest
- Service layer mocking with Jest
- Database testing with mongodb-memory-server
- Async/await test patterns
*Refer to [node_testing.md](node_testing.md) for detailed patterns.*
### Python Testing
**Focus Areas**: API testing, fixtures, parametrized tests
**Key Frameworks**: Pytest, unittest, FastAPI TestClient
**Patterns**:
- FastAPI/Django/Flask API testing
- Pytest fixtures for setup/teardown
- Parametrized tests for similar scenarios
- SQLAlchemy integration testing
*Refer to [python_testing.md](python_testing.md) for detailed patterns.*
### Java / Kotlin Testing
**Focus Areas**: Spring Boot testing, REST API testing, JPA integration
**Key Frameworks**: JUnit 5, Mockito, Spring Boot Test, RestAssured
**Patterns**:
- @SpringBootTest for integration tests
- MockMvc for API testing
- TestContainers for database testing
- JPA repository testing
*Refer to [java_testing.md](java_testing.md) for detailed patterns.*
### .NET / C# Testing
**Focus Areas**: ASP.NET Core testing, Entity Framework, API integration
**Key Frameworks**: xUnit, NUnit, MSTest, FluentAssertions, Moq
**Patterns**:
- WebApplicationFactory for API tests
- In-memory databases for EF Core
- Mocking with Moq
- Integration test slices
*Refer to [dotnet_testing.md](dotnet_testing.md) for detailed patterns.*
### Go Testing
**Focus Areas**: HTTP handlers, table-driven tests, interface testing
**Key Frameworks**: testing package, testify, httptest
**Patterns**:
- Table-driven test patterns
- httptest for HTTP handler testing
- Interface mocking
- Subtests for organized test cases
*Refer to [go_testing.md](go_testing.md) for detailed patterns.*
### PHP Testing
**Focus Areas**: Laravel/Symfony testing, database factories, feature tests
**Key Frameworks**: PHPUnit, Pest, Laravel Dusk
**Patterns**:
- Laravel HTTP tests
- Database factories and seeders
- Feature vs unit tests
- Browser testing with Dusk
*Refer to [php_testing.md](php_testing.md) for detailed patterns.*
### Rust Testing
**Focus Areas**: Unit tests, integration tests, async testing
**Key Frameworks**: Built-in test framework, mockall, tokio-test
**Patterns**:
- Module-level unit tests
- Integration test directory structure
- Async test patterns with tokio
- Mock traits with mockall
*Refer to [rust_testing.md](rust_testing.md) for detailed patterns.*
### React / Frontend Testing
**Focus Areas**: Component testing, user interaction, integration tests
**Key Frameworks**: Vitest, Jest, React Testing Library, Cypress
**Patterns**:
- Component rendering tests
- User event simulation
- API mocking with MSW
- E2E tests with Cypress
*Refer to [react_testing.md](react_testing.md) for detailed patterns.*
### Vue.js Testing
**Focus Areas**: Component testing, Vuex, composables testing
**Key Frameworks**: Vitest, Vue Test Utils, Cypress
**Patterns**:
- Component mounting and testing
- Vuex store testing
- Composables testing
- Router testing
*Refer to [vue_testing.md](vue_testing.md) for detailed patterns.*
### Next.js Testing
**Focus Areas**: API routes, page components, SSR/SSG testing
**Key Frameworks**: Jest, Vitest, Playwright, Cypress
**Patterns**:
- API route testing
- Page component testing
- Server-side rendering tests
- E2E testing with Playwright
*Refer to [next_testing.md](next_testing.md) for detailed patterns.*
### NestJS Testing
**Focus Areas**: Controller testing, service testing, E2E testing
**Key Frameworks**: Jest, Supertest, @nestjs/testing
**Patterns**:
- Unit tests with TestingModule
- E2E tests with Supertest
- Mocking providers
- Database integration tests
*Refer to [nest_testing.md](nest_testing.md) for detailed patterns.*
### React Native Testing
**Focus Areas**: Component testing, navigation, native module mocking
**Key Frameworks**: Jest, React Native Testing Library, Detox
**Patterns**:
- Component testing
- Navigation testing
- Native module mocking
- E2E with Detox
*Refer to [react_native_testing.md](react_native_testing.md) for detailed patterns.*
## Test Quality Standards
### Readability
- ✅ Clear, descriptive test names: `should reject payment when card is expired`
- ✅ Self-documenting: Test describes the behavior being verified
- ✅ Minimal logic: Tests should be straightforward, not complex
- ✅ Follow AAA pattern: Arrange, Act, Assert
### Isolation
- ✅ Independent tests: Each test can run alone or in any order
- ✅ Clean state: Reset databases, clear caches between tests
- ✅ No shared state: Avoid global variables or test interdependencies
- ✅ Parallel execution: Tests can run concurrently
### Performance
- ✅ Fast execution: Integration tests should complete in seconds
- ✅ Parallel ready: Design tests to run concurrently
- ✅ Optimize setup: Use beforeAll/beforeEach wisely
- ✅ Clean teardown: Proper cleanup after tests
### Maintainability
- ✅ DRY principle: Extract common setup into helpers
- ✅ Consistent patterns: Use the same approach across codebase
- ✅ Version controlled: Treat test code like production code
- ✅ Well documented: Comment complex test scenarios
## Mocking Strategy
### When to Mock
**MOCK** external dependencies:
- External APIs and third-party services
- Email/SMS services
- Payment gateways
- File systems (in unit tests)
- Time/date functions
**DON'T MOCK** for integration tests:
- Databases (use test containers instead)
- Internal services (test real interactions)
- Simple utilities
- Framework functions
### Mocking Patterns
```javascript
// Node.js - Jest mocking
jest.mock('external-service');
const mockService = require('external-service');
mockService.someMethod.mockResolvedValue({ data: 'test' });
// Python - Pytest fixtures
@pytest.fixture
def mock_external_api(mocker):
return mocker.patch('app.services.external_api.call')
// Java - Mockito
@Mock
private ExternalService externalService;
when(externalService.getData()).thenReturn(testData);
// .NET - Moq
var mockService = new Mock<IExternalService>();
mockService.Setup(x => x.GetData()).Returns(testData);
```
## Output Format
### Generated Test File Template
```language
// tests/integration/api/users.test.{ext}
// Imports for test framework and utilities
import { test framework imports };
import { application imports };
import { test helpers and fixtures };
// Describe test suite
describe('API: User Endpoints', () => {
// Setup/teardown hooks
beforeAll(async () => {
// Initialize test database, server, etc.
});
afterAll(async () => {
// Cleanup resources
});
beforeEach(async () => {
// Reset state before each test
});
// Test cases following AAA pattern
describe('POST /api/users', () => {
it('should create user with valid data', async () => {
// Arrange
const userData = createValidUserData();
// Act
const response = await makeRequest('POST', '/api/users', userData);
// Assert
expect(response.status).toBe(201);
expect(response.body).toMatchObject({
id: expect.any(String),
email: userData.email
});
});
it('should reject invalid email format', async () => {
// Arrange
const invalidData = { ...validData, email: 'invalid' };
// Act
const response = await makeRequest('POST', '/api/users', invalidData);
// Assert
expect(response.status).toBe(400);
expect(response.body.error).toContain('email');
});
});
});
```
## Best Practices
### Test Organization
- Group related tests using describe/context blocks
- Mirror source code directory structure
- Use clear, descriptive file names
- Separate unit tests from integration tests
### Test Data
- Use factory functions for test data creation
- Create reusable fixtures
- Use realistic data that mimics production
- Clean up test data after tests
### Assertions
- Use specific assertions (toBe, toEqual, toContain)
- Assert on behavior, not implementation
- Include negative assertions where appropriate
- Check both success and error cases
### Error Handling
- Test error scenarios explicitly
- Verify error messages and status codes
- Test exception handling
- Check error recovery mechanisms
## References
For detailed, language-specific testing patterns and examples, refer to the individual skill files in this directory.Related Skills
track-generation
This skill generates normalized BigWig (.bw) tracks (and/or fold-change tracks) from BAM files for ATAC-seq and ChIP-seq visualization. It handles normalization (RPM or fold-change) and Tn5 offset correction automatically. What's more, this skill can help user visualize the signal profiles around TSS or target regions. Use this skill when you have filtered and generated the clean BAM file (e.g. `*.filtered.bam`).
testing-tauri-apps
Guides developers through testing Tauri applications including unit testing with mock runtime, mocking Tauri APIs, WebDriver end-to-end testing with Selenium and WebdriverIO, and CI integration with GitHub Actions.
testing-strategy-python
Python/FastAPI/Django testing conventions. pytest, fixtures, httpx, TestClient, factory_boy. Use when writing or reviewing Python tests.
testing-strategy-builder
Use this skill when creating comprehensive testing strategies for applications. Provides test planning templates, coverage targets, test case structures, and guidance for unit, integration, E2E, and performance testing. Ensures robust quality assurance across the development lifecycle.
testing-skills-activation
Use when creating or refining Claude Code skills to validate that skill descriptions trigger correctly - provides systematic testing methodology for skill activation patterns using test cases and automated evaluation
Testing Skill
Automatiza pruebas y diagnósticos del sistema SmartK et sin perder tiempo
testing-qa
Comprehensive testing and QA workflow covering unit testing, integration testing, E2E testing, browser automation, and quality assurance.
testing-principles
Language-agnostic testing principles including TDD, test quality, coverage standards, and test design patterns. Use when writing tests, designing test strategies, or reviewing test quality.
testing-patterns
TDD and unit testing guidance for Crispy CRM. Use when writing tests, implementing TDD, debugging test failures, or setting up test infrastructure. Covers Vitest patterns, React Admin component testing, Zod schema validation testing, Supabase mocking, E2E with Playwright, and manual E2E testing with Claude Chrome. Integrates with verification-before-completion for test verification.
testing-builder
Automatically generates comprehensive test suites (unit, integration, E2E) based on code and past testing patterns. Use when user says "write tests", "test this", "add coverage", or after fixing bugs to create regression tests. Eliminates testing friction for ADHD users.
Testing Anti-Patterns
This skill should be used when encountering "flaky tests", "test maintenance issues", "slow test suites", "brittle tests", "test code smells", "test debugging problems", or when tests are hard to understand, maintain, or debug.
testcontainers-integration-tests
Use when integration tests require real infrastructure (database, message queue, cache) or when mocking infrastructure is insufficient. Defines container lifecycle, test isolation, and performance optimization for Testcontainers-based testing.