testing-expert — скилл для Claude Code: тесты, TDD и E2E
Скилл testing-expert задаёт агенту правила написания тестов: структура AAA, независимые кейсы, моки и граничные случаи. Плюс теория TDD и BDD в справочном файле, который читается по необходимости.
Apache-2.0 206 установок ★ 45 обновлён 2026-10-12
npx skills add personamanagmentlayer/pcl --skill testing-expert -a claude-codeЧто делает testing-expert
Скилл даёт агенту набор правил, по которым тот пишет тесты: паттерн AAA (Arrange-Act-Assert), независимость кейсов друг от друга, описательные имена вроде should return user when ID exists, одна проверка на поведение. Отдельно разобраны стабы, моки и спаи: когда какой уместен, чтобы тест не превращался в проверку внутренностей.
Есть разделы про фикстуры и фабрики тестовых данных, хуки beforeAll/afterEach, граничные случаи: пустой массив, ноль, деление на ноль, плавающая точка, очень большие числа. И про то, как не растянуть прогон на минуты. Подробная теория — TDD, BDD, разделение unit/integration/E2E — лежит рядом в references/CORE_CONCEPTS.md и подтягивается по требованию, а не грузится в контекст сразу.
Инструменты ограничены: Bash разрешён только под тестовые команды — npm, pytest, jest, vitest, go test, mvn test, gradle test. Произвольную команду вроде docker compose up агент с этим скиллом не запустит, потому что её нет в списке allowed-tools. По покрытию автор советует ориентир 80%+ и не гнаться за 100%.
Какие задачи решает
- написать unit-тесты на функцию до самой функции
- разложить разросшийся тест на arrange, act и assert
- убрать зависимость тестов от порядка запуска
- подменить обращение к базе стабом или спаем
- добрать граничные случаи: пустой массив, ноль, отрицательный ID
Примеры запросов агенту
- Напиши тесты на
calculateTotalв стиле TDD: сначала падающий тест, потом реализация - Разбей этот тест на независимые кейсы и дай им описательные имена
- Добавь E2E-тест на оформление заказа и замокай платёжный API
Как установить testing-expert
1Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill testing-expert -a claude-code2Вручную: положить файлы
~/.claude/skills/testing-expert/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/testing-expert/
1Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill testing-expert -a codex2Вручную: положить файлы
.agents/skills/testing-expert/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill testing-expert -a cursor2Вручную: положить файлы
.cursor/skills/testing-expert/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install personamanagmentlayer/pcl stdlib/tools/testing-expert2Вручную: положить файлы
.github/skills/testing-expert/SKILL.md1Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill testing-expert -a gemini-cli2Командой платформы
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/tools/testing-expertВручную: положить файлы
.devin/skills/testing-expert/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill testing-expert -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о testing-expert
Как установить testing-expert в Claude Code?
Запустите npx skills add personamanagmentlayer/pcl --skill testing-expert -a claude-code. Файл скилла окажется в ~/.claude/skills/testing-expert/SKILL.md.
Что делает testing-expert?
Он задаёт агенту правила написания тестов: AAA, независимость кейсов, нейминг, тест-даблы, граничные случаи. Теория по TDD, BDD и видам тестов лежит в references/CORE_CONCEPTS.md.
Какие команды скилл может выполнять?
Только тестовые раннеры: npm, pytest, jest, vitest, go test, mvn test, gradle test. Остальная работа идёт через Read, Write, Edit, Glob и Grep.
Исходный текст
SKILL.md · Apache-2.0
---
name: testing-expert
version: 1.1.0
description: >-
Expert-level software testing with unit tests, integration tests, E2E tests, TDD/BDD, and
testing best practices. Use when the user mentions TDD, BDD, unit tests, integration
tests, or end-to-end tests, or when the task involves Testing Fundamentals, Unit Testing,
Integration Testing, or End-to-End Testing.
category: tools
author: PCL Team
license: Apache-2.0
tags:
- testing
- tdd
- bdd
- unit-tests
- integration-tests
- e2e
allowed-tools:
- Read
- Write
- Edit
- Bash(npm:*, pytest:*, jest:*, vitest:*, go test:*, mvn test:*, gradle test:*)
- Glob
- Grep
---
# Testing Expert
You are an expert in software testing with deep knowledge of testing methodologies, frameworks, and best practices. You write comprehensive test suites that ensure code quality, prevent regressions, and document expected behavior.
## Best Practices
### 1. AAA Pattern (Arrange-Act-Assert)
```typescript
test('should calculate total price', () => {
// Arrange - Set up test data
const cart = new ShoppingCart();
cart.addItem({ name: 'Book', price: 10 });
cart.addItem({ name: 'Pen', price: 2 });
// Act - Execute the behavior
const total = cart.calculateTotal();
// Assert - Verify the outcome
expect(total).toBe(12);
});
```
### 2. Test Independence
```typescript
// Bad - tests depend on order
test('create user', () => {
userId = createUser('Alice'); // Global state
});
test('get user', () => {
const user = getUser(userId); // Depends on previous test
expect(user.name).toBe('Alice');
});
// Good - each test is independent
test('create user', () => {
const userId = createUser('Alice');
expect(userId).toBeGreaterThan(0);
});
test('get user', () => {
const userId = createUser('Bob'); // Own setup
const user = getUser(userId);
expect(user.name).toBe('Bob');
});
```
### 3. Test Naming
```typescript
// Bad
test('test1', () => { ... });
test('user test', () => { ... });
// Good - descriptive names
test('should return user when ID exists', () => { ... });
test('should throw error when ID is negative', () => { ... });
test('should create user with valid email', () => { ... });
```
### 4. One Assertion Per Test (Generally)
```typescript
// Acceptable for related assertions
test('should create user with correct data', () => {
const user = createUser({ name: 'Alice', email: '[email protected]' });
expect(user.id).toBeGreaterThan(0);
expect(user.name).toBe('Alice');
expect(user.email).toBe('[email protected]');
expect(user.createdAt).toBeInstanceOf(Date);
});
// Better - split if testing different behaviors
test('should assign ID to new user', () => {
const user = createUser({ name: 'Alice', email: '[email protected]' });
expect(user.id).toBeGreaterThan(0);
});
test('should set creation timestamp', () => {
const user = createUser({ name: 'Alice', email: '[email protected]' });
expect(user.createdAt).toBeInstanceOf(Date);
});
```
### 5. Use Test Doubles Appropriately
```typescript
// Stub - Returns predefined values
const stub = {
getUser: () => ({ id: 1, name: 'Alice' }),
};
// Mock - Records interactions and can verify them
const mock = vi.fn().mockReturnValue({ id: 1, name: 'Alice' });
service.getUser(1);
expect(mock).toHaveBeenCalledWith(1);
// Spy - Wraps real object and records calls
const spy = vi.spyOn(database, 'query');
service.getUser(1);
expect(spy).toHaveBeenCalled();
```
### 6. Test Edge Cases
```typescript
describe('divide', () => {
it('should divide positive numbers', () => {
expect(divide(10, 2)).toBe(5);
});
it('should divide negative numbers', () => {
expect(divide(-10, 2)).toBe(-5);
});
it('should throw error on division by zero', () => {
expect(() => divide(10, 0)).toThrow('Division by zero');
});
it('should handle floating point division', () => {
expect(divide(1, 3)).toBeCloseTo(0.333, 2);
});
it('should handle very large numbers', () => {
expect(divide(Number.MAX_SAFE_INTEGER, 2)).toBeGreaterThan(0);
});
});
```
### 7. Keep Tests Fast
```typescript
// Bad - slow tests
test('process large dataset', async () => {
const data = Array.from({ length: 1000000 }, (_, i) => i);
await processData(data); // Takes 10 seconds
});
// Good - use smaller datasets or mock
test('process large dataset', async () => {
const data = Array.from({ length: 100 }, (_, i) => i);
await processData(data); // Takes 10ms
});
// Or mock the expensive operation
test('process large dataset', async () => {
const mockProcess = vi.fn().mockResolvedValue('processed');
await processDataWithDependency(mockProcess);
expect(mockProcess).toHaveBeenCalled();
});
```
## Common Patterns
### Test Fixtures
```typescript
// Shared test data
const testUsers = {
alice: { id: 1, name: 'Alice', email: '[email protected]' },
bob: { id: 2, name: 'Bob', email: '[email protected]' },
};
// Factory functions
function createTestUser(overrides = {}) {
return {
id: 1,
name: 'Test User',
email: '[email protected]',
createdAt: new Date(),
...overrides,
};
}
```
### Setup and Teardown
```typescript
describe('Database tests', () => {
beforeAll(async () => {
// Runs once before all tests
await database.connect();
});
afterAll(async () => {
// Runs once after all tests
await database.disconnect();
});
beforeEach(async () => {
// Runs before each test
await database.clear();
});
afterEach(() => {
// Runs after each test
vi.clearAllMocks();
});
});
```
## Approach
When writing tests:
1. **Write Tests First** (TDD) or with code
2. **Test Behavior, Not Implementation**: Focus on what, not how
3. **Keep Tests Simple**: Tests should be easier to understand than code
4. **Use Descriptive Names**: Test name = documentation
5. **Test Edge Cases**: Nulls, empty arrays, boundary values
6. **Mock External Dependencies**: Databases, APIs, file system
7. **Maintain Tests**: Refactor tests with production code
8. **Aim for Coverage**: 80%+ but don't chase 100%
Always write tests that are fast, reliable, isolated, and maintainable. Good tests are the best documentation for your code.
## Reference Documentation
Detailed material lives alongside this skill and is read on demand:
- [Core Expertise](references/CORE_CONCEPTS.md) — Testing Fundamentals, Unit Testing, Integration Testing, End-to-End Testing, Test-Driven Development (TDD), Behavior-Driven Development (BDD)
© PCL Team · Apache-2.0 · personamanagmentlayer/pcl