dart-add-unit-test

A guide for writing Dart and Flutter unit tests with package:test, the standard Dart testing library. Unit tests check small pieces of code separately from the rest of an application.

In plain words
What is it for?
Use it to organize test files, write test cases and grouped checks, test asynchronous code, and verify returned values or expected errors.
Why use it?
It provides a consistent test layout and structure, making code behavior easier to verify and regressions easier to catch.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/flutter/agent-plugins/dart-add-unit-test
Any agent
npx skills add flutter/agent-plugins --skill dart-add-unit-test
Clone the repo
git clone --depth 1 https://github.com/flutter/agent-plugins

Made for: Claude Code, Codex.

Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,067 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00039 $0.01067
Opus 5 $0.00019 $0.00534
Sonnet 5 $0.00008 $0.00213
Haiku 4.5 $0.00004 $0.00107

Measured 2d ago against content hash 02428fa20c2c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dart-add-unit-test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

skills/dart-add-unit-test/SKILL.md · 123 lines

How it starts

The opening of the file, as written. The whole thing — 123 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testing Dart and Flutter Applications

Contents

Structuring Test Files

Organize test files to mirror the lib directory structure to maintain predictability.

  • Place all test code within the test directory at the root of the package.
  • Append _test.dart to the end of all test file names (e.g., lib/src/utils.dart should be tested in test/src/utils_test.dart).
  • If writing integration tests, place them in an integration_test directory at the root of the package.

Writing Tests

Utilize package:test as the standard testing library for Dart applications.

  • Import package:test/test.dart (or package:flutter_test/flutter_test.dart for Flutter).
  • Group related tests using the group() function to provide shared context.
  • Define individual test cases using the test() function.
  • Validate outcomes using the expect() function alongside matchers (e.g., equals(), isTrue, throwsA()).
  • Write asynchronous tests using standard async/await syntax. The test runner automatically waits for the Future to complete.
  • Manage test setup and teardown using setUp() and tearDown() callbacks.
  • If testing code that relies on dependency injection, use package:mockito alongside package:test to generate mock objects, configure fixed scenarios, and verify interactions.

Executing Tests

Select the appropriate test runner based on the project type and test location.

  • If working on a pure Dart project, execute tests using the dart test command.
  • If working on a Flutter project, execute tests using the flutter test command.
  • If running integration tests, explicitly specify the directory path, as the default runner ignores it: dart test integration_test or flutter test integration_test.

Test Implementation Workflow

Follow this sequential workflow when implementing new test suites. Copy the checklist to track your progress.

Read the full file on GitHub · 123 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 123 lines · 39 tokens per session scan A 02428fa20c2c

Subscribe to this mod's changes

dart-add-unit-test is a skill published in the GitHub repository flutter/agent-plugins (2,895 stars, last pushed 4d ago), licensed BSD-3-Clause. It adds 39 tokens to every session and 1,067 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

studio-testing

Testing strategy for Supabase Studio. Use when writing tests, deciding whether a change needs tests and which type, extracting logic from components into testable utility functions, or reviewing test coverage. Covers unit tests, component tests, and E2E test selection criteria.

supabase/supabase · 55 tokens

tdd-workflow

Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.

affaan-m/ECC · 43 tokens

pest-testing

Use this skill for Pest PHP testing in Laravel projects only. Trigger whenever any test is being written, edited, fixed, or refactored — including fixing tests that broke after a code change, adding assertions, converting PHPUnit to Pest, adding datasets, and TDD workflows. Always activate when the user asks how to…

coollabsio/coolify · 171 tokens

frontend-unit-testing

Write comprehensive, behaviour-driven unit tests for Gradio frontend Svelte components using Vitest browser mode, Playwright, and the @self/tootils test utilities.

gradio-app/gradio · 37 tokens

write-sglang-test

Guide for writing SGLang CI/UT tests. Covers CustomTestCase, CI registration, server fixtures, model selection, mock testing, and test placement. Always read test/README.md for the full CI layout, how to run tests, and extra tips. Use when creating new tests, adding CI test cases, writing unit tests, or when the user…

sgl-project/sglang · 88 tokens

checking-changes

Validates all code changes before committing by running format, lint, type, and unit test checks. Use after making backend (Python) or frontend (TypeScript) changes, before committing or finishing a work session.

streamlit/streamlit · 47 tokens