Skip to content
Back to skills

Write Tests

ASecurity

Write readable tests for new or changed ADK code and show that coverage of the touched modules didn't drop. Use after implementing a feature or fix in the polyai-adk repo, or when asked to add test coverage.

  • 84 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentsapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add polyai/adk --skill write-tests --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Write Tests?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Write Tests
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/polyai-write-tests/badge)](https://www.skillsdirectory.com/skills/polyai-write-tests)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: write-tests
description: Write readable tests for new or changed ADK code and show that coverage of the touched modules didn't drop. Use after implementing a feature or fix in the polyai-adk repo, or when asked to add test coverage.
metadata:
  internal: true
---

# Write tests for an ADK change

## 1. Measure first

Run `uv run pytest src/poly/tests/ --cov=poly --cov-report=term-missing` and note the coverage
of each module the change touches.

## 2. Write the tests

- **Placement:** add to the existing file and class for the area:
  - `resources_test.py` for resources
  - `project_test.py` for project logic
  - `cli_test.py` for argument parsing and command output
  - `tests/api/` for handlers
  - `tests/call/` for voice calls
  - The `*_test.py` file named after the feature (`metrics_test.py`, `rtc_test.py`, …)

  Only create a new file or class when nothing fits.
- **Fixtures:** use real objects and the fixture projects in `src/poly/tests/test_projects/`.
  When a resource gains a field or a new resource type is added, add an example to
  `test_projects/test_project/` as well.
- **Mocks:** mock only at the API or filesystem boundary, one `@patch` per test where possible.
  Don't assert that a mock was called when you could assert on the result.
- **Style:** `unittest.TestCase` classes. Names read as `test_<scenario>_<expected_outcome>`,
  with one behaviour per test and a short docstring.
- **Cover:** the happy path, edge cases (empty, `None`, missing fields), errors (`ValueError` for
  bad input), and a YAML round-trip (`to_yaml_dict` → `from_yaml_dict`) for resources.
- Never test generated code under `handlers/protobuf/` or `types/`.

## 3. Measure again

Re-run the coverage command and the full suite. Then run `uv run ruff check . --fix` and
`uv run ruff format .`.

## Report

The tests you added (file and class), and the before → after coverage for each touched module.
If coverage dropped, say which lines are uncovered and why.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.