Testing Framework
Set up test infrastructure, choose frameworks, and author focused test suites across multiple languages. Treat this skill as a router: select the one testing module that matches the codebase, then load only the relevant references/templates.
When to Use This Skill
- Setting up test infrastructure from scratch
- Choosing a test framework for a new project
- Writing new tests (unit, integration, E2E)
- Adding accessibility testing to an existing suite
- Configuring CI/CD test automation
- Testing shell scripts with ShellSpec or BATS
When NOT to Use This Skill
- TDD methodology (red-green-refactor) → use
test-driven-development - Diagnosing and fixing bugs → use
debugging - Reviewing existing code or PRs → use
code-review - Performance benchmarking → use domain-specific profiling tools
- Framework-specific implementation patterns beyond tests → use the language/framework skill first, then return here for test scaffolding
Scope Control
This skill intentionally spans several ecosystems, so avoid loading every module. Pick a lane:
| Need | Use |
|---|---|
| Choose a test stack | Decision tree + references/test-runners.md |
| Add tests to a React/Next.js app | Next.js/React module + Playwright/RTL templates |
| Add tests to Rust code | Rust module + AAA references |
| Add tests to PHP/TYPO3 | TYPO3/PHP module |
| Test shell scripts | ShellSpec/BATS module |
| Improve existing suite quality | scripts/analyze-test-quality.py + anti-pattern references |
If a request needs two or more ecosystems, handle them as separate passes so the output stays practical.
Decision Tree
What do you need to test?
│
├─ Rust application
│ └─ cargo test + AAA pattern → templates/rust/
│
├─ Next.js / React application
│ ├─ Component tests → Vitest + React Testing Library → assets/nextjs/
│ ├─ E2E tests → Playwright → templates/e2e/
│ └─ Accessibility → axe-core → references/a11y-testing.md
│
├─ PHP / TYPO3 extension
│ └─ PHPUnit + Playwright E2E → templates/typo3/
│
├─ Shell / Bash scripts
│ ├─ BDD-style → ShellSpec → assets/shellspec/
│ └─ TAP-compliant → BATS → scripts/init_bats_project.sh
│
├─ Existing code needs coverage analysis
│ └─ scripts/analyze-test-quality.py + references/anti-patterns.md
│
└─ CI/CD integration needed
└─ GitHub Actions or GitLab CI → references/ci-cd.md
Testing Modules
1. Rust Unit Testing
High-quality Rust unit tests following AAA pattern with deployment confidence.
Key Principles:
- Test naming:
test_<function>_<scenario>_<expected_behavior> - AAA Pattern: Arrange-Act-Assert with clear sections
- Mock external dependencies, not pure functions
- Speed target: milliseconds per test
Quick Start:
#[tokio::test]
async fn test_withdraw_valid_amount_decreases_balance() {
// Arrange
let mut account = Account::new(100);
// Act
let result = account.withdraw(30).await;
// Assert
assert!(result.is_ok());
assert_eq!(account.balance(), 70);
}
Resources:
- Templates:
templates/rust/unit-test.md,templates/rust/async-test.md - References:
references/aaa-pattern.md,references/naming-conventions.md - Quality analysis:
scripts/analyze-test-quality.py
2. E2E Testing with Playwright
Automated E2E testing with LLM-powered visual debugging.
Workflow Phases:
- Application Discovery
- Playwright Setup
- Pre-flight Health Check
- Test Generation
- Screenshot Capture
- Visual Analysis
- Regression Detection
- Fix Generation
- Test Suite Export
Quick Start:
import { test, expect } from '@playwright/test';
test('user creates new entity', async ({ page }) => {
await page.goto('/entities');
await page.getByRole('button', { name: /create/i }).click();
await page.getByLabel(/name/i).fill('New Item');
await page.getByRole('button', { name: /save/i }).click();
await expect(page.getByText('New Item')).toBeVisible();
});
Resources:
- Workflow:
assets/e2e-workflow/phase-*.md - Templates:
templates/e2e/playwright.config.template.ts - Data:
assets/e2e-data/playwright-best-practices.md
3. Next.js Testing Stack
Complete testing setup for Next.js with Vitest, RTL, and Playwright.
Setup:
python scripts/generate_test_deps.py --nextjs-version <version> --typescript
Test Patterns:
// Component test with accessibility
import { render, screen } from '@/test/utils/render'
import { axe } from '@axe-core/playwright'
it('has no accessibility violations', async () => {
const { container } = render(<EntityCard entity={mockEntity} />)
const results = await axe(container)
expect(results.violations).toHaveLength(0)
})
Resources:
- Config templates:
assets/nextjs/vitest.config.ts,assets/nextjs/playwright.config.ts - Examples:
examples/nextjs/ - References:
references/a11y-testing.md
4. TYPO3/PHP Testing
PHPUnit-based testing for TYPO3 extensions with E2E support.
Test Types:
- Unit tests (no database, fast)
- Functional tests (with database)
- E2E tests (Playwright browser automation)
- Fuzz tests (security, input mutation)
- Mutation tests (test quality verification)
Quick Start:
# Setup
scripts/setup-testing.sh --with-e2e
# Generate test
scripts/generate-test.sh unit UserValidator
scripts/generate-test.sh functional ProductRepository
scripts/generate-test.sh e2e backend-module
Resources:
- Templates:
templates/typo3/ - References:
references/functional-testing.md,references/mutation-testing.md - Scripts:
scripts/setup-testing.sh,scripts/generate-test.sh
5. Shell Script Testing
Testing frameworks for Bash and POSIX shell scripts.
ShellSpec (BDD-style)
Describe 'Calculator'
Include lib/calculator.sh
It 'performs addition'
When call add 2 3
The output should eq 5
End
End
BATS (TAP-compliant)
@test "describe expected behavior" {
run my_command arg1 arg2
assert_success
assert_output --partial "expected substring"
}
Resources:
- ShellSpec template:
assets/shellspec/spec_template.sh - BATS scripts:
scripts/init_bats_project.sh - References:
references/gotchas.md,references/advanced-patterns.md
6. Skill Testing Framework
Validation tools for testing skills with input/output pair validation.
Test Types:
- Unit tests for individual components
- Integration tests for complete workflows
- Regression tests against baselines
Quick Start:
# Generate test template
scripts/generate_test_template.py /path/to/skill --output tests.json
# Run tests
scripts/run_tests.py tests.json --skill-path /path/to/skill
# Validate results
scripts/validate_test_results.py actual.txt expected.txt
Resources:
- Template:
assets/skill-testing/test_template.json - Scripts:
scripts/run_tests.py,scripts/generate_test_template.py - References:
references/test_patterns.md,references/writing_tests.md
Available Scripts
| Script | Purpose |
|---|---|
scripts/analyze-test-quality.py |
Analyze Rust test file quality |
scripts/setup-testing.sh |
Set up TYPO3 testing infrastructure |
scripts/generate-test.sh |
Generate test class templates |
scripts/validate-setup.sh |
Validate testing setup |
scripts/run_tests.py |
Run skill test suites |
scripts/generate_test_template.py |
Generate test templates |
scripts/validate_test_results.py |
Validate test outputs |
scripts/diagnose_test.sh |
Diagnose ShellSpec test failures |
scripts/init_bats_project.sh |
Initialize BATS project |
scripts/strip_colors.sh |
Strip ANSI colors from output |
scripts/generate_test_deps.py |
Generate Next.js test dependencies |
Reference Documentation
Core Testing Patterns
references/aaa-pattern.md- Arrange-Act-Assert pattern detailsreferences/naming-conventions.md- Test naming best practicesreferences/test-builders.md- Test builder patternsreferences/anti-patterns.md- Common testing anti-patterns to avoidreferences/writing_tests.md- Best practices for effective testingreferences/test_patterns.md- Examples for different skill types
Framework-Specific
references/unit-testing.md- PHP/TYPO3 unit testingreferences/functional-testing.md- Functional testing with databasereferences/functional-test-patterns.md- Container reset, PHPUnit migrationreferences/async-testing.md- Async test patternsreferences/e2e-testing.md- End-to-end testing guidereferences/javascript-testing.md- JavaScript/TypeScript testing
Specialized Testing
references/fuzz-testing.md- Security fuzz testingreferences/mutation-testing.md- Test quality verificationreferences/accessibility-testing.md- axe-core WCAG compliancereferences/a11y-testing.md- Accessibility testing guidelines
CI/CD & Tools
references/ci-cd.md- GitHub Actions, GitLab CI workflowsreferences/ci-integration.md- CI/CD integration patternsreferences/ci-cd-integration.md- E2E CI/CD examplesreferences/test-runners.md- Test orchestration patternsreferences/quality-tools.md- PHPStan, Rector, php-cs-fixerreferences/sonarcloud.md- SonarCloud integration
Shell Testing
references/gotchas.md- BATS common pitfallsreferences/assertions.md- BATS assertion referencereferences/advanced-patterns.md- ShellSpec advanced patternsreferences/troubleshooting.md- Debugging test failuresreferences/collected-experience.md- Lessons learnedreferences/real-world-examples.md- Production patternsreferences/projects.md- Real-world project examples
Templates
Rust
templates/rust/unit-test.md- Basic unit test templatetemplates/rust/async-test.md- Async test templatetemplates/rust/test-builder.md- Test builder pattern
E2E/Playwright
templates/e2e/playwright.config.template.ts- Playwright configtemplates/e2e/test-spec.template.ts- Test spec templatetemplates/e2e/page-object.template.ts- Page Object Modeltemplates/e2e/global-setup.template.ts- Global setuptemplates/e2e/global-teardown.template.ts- Global teardowntemplates/e2e/screenshot-helper.template.ts- Screenshot utilities
TYPO3/PHP
templates/typo3/UnitTests.xml- PHPUnit unit configtemplates/typo3/FunctionalTests.xml- PHPUnit functional configtemplates/typo3/FunctionalTestsBootstrap.php- Bootstrap filetemplates/typo3/github-actions-tests.yml- CI workflowtemplates/typo3/Build/playwright/- Playwright E2E setuptemplates/typo3/example-tests/- Example test classes
Examples
E2E
examples/e2e/react-vite/- React Vite example testsexamples/e2e/reports/- Example analysis reports
Next.js
examples/nextjs/unit-test.ts- Unit test exampleexamples/nextjs/component-test.tsx- Component test exampleexamples/nextjs/e2e-test.ts- E2E test example
Assets
Configuration
assets/nextjs/vitest.config.ts- Vitest configurationassets/nextjs/playwright.config.ts- Playwright configurationassets/nextjs/test-setup.ts- Test setup file
ShellSpec
assets/shellspec/spec_template.sh- ShellSpec test template
Skill Testing
assets/skill-testing/test_template.json- Test suite template
E2E Workflow
assets/e2e-workflow/phase-*.md- Detailed workflow phases
E2E Data
assets/e2e-data/playwright-best-practices.mdassets/e2e-data/accessibility-checks.mdassets/e2e-data/common-ui-bugs.md
Checklists
assets/rust-checklists/pre-commit.md- Pre-commit checklistassets/rust-checklists/review.md- Code review checklist
Best Practices
Universal Testing Principles
- Quality over coverage - Tests should catch real bugs, not boost metrics
- Test naming matters - Names should describe expected behavior
- AAA pattern - Arrange, Act, Assert for clear structure
- Single responsibility - Each test verifies ONE behavior
- Fast tests - Unit tests should run in milliseconds
- Mock external dependencies - APIs, databases, file systems, time
- Don't mock - Value types, pure functions, code under test
Test Organization
- Group tests by feature or domain, not by test type
- Keep fixtures minimal, reusable, and documented
- Ensure each test runs independently
- Apply setUp() and tearDown() consistently
- Document test strategy in AGENTS.md or README
CI/CD Integration
- Generate JUnit reports for CI integration
- Run tests in parallel when possible
- Set up code coverage thresholds
- Configure test artifacts (screenshots, reports)
- Use test tags for selective execution
Troubleshooting
Common Issues
Tests not found:
- Check file naming conventions
- Verify configuration file paths
- Ensure test class extends correct base class
Tests are slow:
- Enable parallel execution
- Mock external dependencies
- Use setup_file() for expensive operations
Flaky tests:
- Check for global state leakage
- Ensure proper cleanup in tearDown
- Mock time/random dependencies
Database errors:
- Verify database driver configuration
- Check fixture format
- Ensure bootstrap file is configured
E2E failures:
- Verify Node.js version
- Install browsers with playwright install
- Check baseURL configuration
External Resources
| Resource | Use For |
|---|---|
| Playwright Docs | E2E testing, Page Objects |
| Vitest Docs | Unit testing, configuration |
| Testing Library | React component testing |
| axe-core | Accessibility testing |
| ShellSpec | Shell script BDD testing |
| BATS | Shell script TAP testing |
| PHPUnit | PHP unit testing |
Anti-Patterns with Solutions
Testing implementation instead of behavior — asserting internal function calls instead of observable outputs.
- Solution: test what the code produces (return values, side effects, DOM output) not how it produces it.
Oversized test fixtures — test setup is 50+ lines for a 3-line assertion.
- Solution: use test builders and factory patterns (references/test-builders.md). Keep fixtures minimal and reusable.
Flaky tests from global state — tests pass locally but fail in CI, or pass/fail unpredictably.
- Solution: mock time/random dependencies, ensure proper cleanup in tearDown, check for global state leakage. See references/troubleshooting.md.
Coverage theater — chasing 100% line coverage while ignoring edge cases and error paths.
- Solution: quality over coverage. Focus testing effort where failures hurt most. 85% meaningful coverage > 100% shallow coverage.
E2E tests for everything — using Playwright for logic that could be unit-tested in milliseconds.
- Solution: use the testing tier pyramid. Unit tests for logic (ms), integration for component interaction (seconds), E2E for critical user workflows (minutes).
Remember: The goal is deployment confidence, not coverage theater.