Пробелы в покрытии тестами

Находит рискованный непокрытый код: запускает coverage, ранжирует пробелы по риску (деньги, авторизация, потеря данных, парсинг), а не по проценту, и предлагает несколько самых важных тестов. Используйте, когда спрашивают, где не хватает тестов, или просят поднять покрытие.

ТестированиеПак: Тестирование91 строкаtest-coverage-gaps

Установка

Выполните одну команду — она сохранит SKILL.md в папку скиллов агента. Перезапустите агента, и он подхватит скилл сам.

Claude Code — macOS, Linux
mkdir -p ~/.claude/skills/test-coverage-gaps && curl -fsSL https://anymodel.org/en/skills/testing/test-coverage-gaps/SKILL.md -o ~/.claude/skills/test-coverage-gaps/SKILL.md
Codex, Cursor — macOS, Linux
mkdir -p ~/.agents/skills/test-coverage-gaps && curl -fsSL https://anymodel.org/en/skills/testing/test-coverage-gaps/SKILL.md -o ~/.agents/skills/test-coverage-gaps/SKILL.md
Claude Code — Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.claude\skills\test-coverage-gaps" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/testing/test-coverage-gaps/SKILL.md -UseBasicParsing -OutFile "$HOME\.claude\skills\test-coverage-gaps\SKILL.md"
Codex, Cursor — Windows PowerShell
New-Item -ItemType Directory -Force "$HOME\.agents\skills\test-coverage-gaps" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/testing/test-coverage-gaps/SKILL.md -UseBasicParsing -OutFile "$HOME\.agents\skills\test-coverage-gaps\SKILL.md"

Другой агент: сохраните файл в его папку скиллов или дайте ему ссылку на файл: https://anymodel.org/en/skills/testing/test-coverage-gaps/SKILL.md

SKILL.md

Исходник

Test Coverage Gaps

A coverage percentage says how much code ran, not how well it is protected. Your goal is to find the untested code that would hurt most if it broke, and propose a short list of tests for it.

Workflow

1. Get a coverage report

Find how the project already measures coverage and use that first. Typical commands:

# JavaScript / TypeScript
npx vitest run --coverage            # or: npx jest --coverage
# Python
pytest --cov=src --cov-report=term-missing --cov-branch
# Go
go test ./... -coverprofile=cover.out && go tool cover -func=cover.out
# Java (Maven + JaCoCo)
mvn test jacoco:report
  • If no coverage tool is configured, ask before adding a dependency; Go has it built in, Python and Node need a package.
  • Enable branch coverage if available: a line can run while one side of its if never does.
  • Run the whole suite and note failing tests first. Coverage from a broken suite is misleading.
  • Write coverage output files (coverage/, .coverage, cover.out) outside git; check .gitignore.

2. Collect the gaps

List files and functions with uncovered lines or branches. Focus on the per-line and per-branch detail (term-missing, lcov, go tool cover -html), not the total.

Ignore code that is not worth testing: generated code, trivial getters, pure configuration, type definitions, thin wrappers around a framework, dead code (report dead code separately for deletion).

3. Rank by risk, not by size

For each gap, score the damage if it were wrong, and how likely it is to change or break:

Risk area Examples Weight
Money prices, discounts, taxes, refunds, currency rounding, billing very high
Auth and permissions login, token checks, role checks, ownership checks very high
Data loss or corruption deletes, migrations, overwrites, transactions, sync very high
Parsing and validation user input, file formats, dates, encodings, webhooks high
External contracts API handlers, serialization, retries, idempotency high
Concurrency and state locks, queues, caching, scheduling medium to high
Error paths catch blocks, timeouts, fallbacks medium
Presentation, glue formatting, UI wiring, logging low

Raise the score for code that changes often (see the command below) and for code that has caused bugs before (search the history for "fix").

git log --since=6.months --name-only --pretty=format: -- src | sort | uniq -c | sort -rn | head -20

4. Propose the tests that matter

Pick the top 3 to 7 gaps. For each, write:

  • Where: file and function, and the uncovered lines or branches.
  • Why it matters: the concrete failure (for example "a negative quantity yields a negative total").
  • Test: the cases to write in one sentence each, and the level (unit, integration, E2E).
  • Cost: easy, needs a fake, needs a database or service.

Prefer a few strong behavior tests over many shallow ones. A test that executes a line without asserting anything inflates coverage and protects nothing.

5. Optionally write them

If the user asked you to write the tests, do the top items, following the project's test style, and run coverage again. Report the before and after for the files you touched. Do not chase a global threshold by padding tests.

Report format

  • Overall numbers (lines and branches) and the command used, in one line.
  • Ranked table: risk, location, why, proposed test, cost.
  • Code judged not worth testing, and any dead code found.
  • Suspected bugs spotted while reading the uncovered code.
  • Tests written, if any, with the new numbers.

Pitfalls

  • Treating 100 percent as the goal. Chasing it produces tests of getters and mocks.
  • Trusting coverage from tests that assert nothing; scan a few covered but critical functions for real assertions.
  • Missing branches: a covered if with no test for the else.
  • Reading the percentage of the whole repository; look at the risky modules.
  • Adding a coverage gate or changing CI thresholds without asking the user.
  • Writing tests that only lock in current buggy behavior. If the code looks wrong, report it instead.

Source: AnyModel skills catalog · License: CC BY 4.0

Подключить через AnyModel API

Скилл работает на той модели, которую использует агент. Подключите Claude Code, Codex или Cursor к AnyModel и запускайте его на Claude, GPT, Gemini и других моделях по одному ключу — оплата за токены, без подписки.

Ещё из пака Тестирование

Разработка через тесты (TDD)

Ведёт изменение по циклу red, green, refactor: пишет падающий тест с описанием поведения, добавляет минимум кода для прохождения и рефакторит на зелёных тестах. Для фич и багфиксов с тестом вперёд.

Написание юнит-тестов

Пишет точечные юнит-тесты для существующего кода: находит публичное поведение, покрывает крайние случаи и ошибки, делает осмысленные проверки и следует фреймворку и стилю проекта. Для добавления тестов к функции или модулю.

E2E-тесты на Playwright

Пишет стабильные браузерные E2E-тесты на Playwright: пользовательские локаторы, web-first проверки вместо sleep, изолированные данные, трейсы при падении и отладка в headed-режиме. Используйте, когда просят добавить или починить браузерные E2E-тесты.

Контрактные тесты API

Пишет тесты HTTP API: коды ответов, схемы, формат ошибок, авторизация и права, идемпотентность, пагинация, без зависимости от состояния базы. Для тестирования REST и JSON API.