# Dart add unit test

> Dart add unit test is an open-source agent skill for developer tools. Guides your agent to write and organize Dart and Flutter unit tests with package:test. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/flutter/agent-plugins/tree/main/skills/dart-add-unit-test
- **Repository:** https://github.com/flutter/agent-plugins
- **GitHub stars:** 3,223
- **License:** BSD-3-Clause
- **Skill name:** dart-add-unit-test
- **Collection:** https://github.com/flutter/agent-plugins
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-30

## About

This skill tells the agent how to lay out test code for a Dart or Flutter package: tests live in the test directory and mirror the lib structure, with files named with a _test.dart suffix. It covers the core package:test API, including grouping cases, asserting with matchers, handling async tests, and setup and teardown callbacks. Integration tests are kept in a separate integration_test directory.

The skill also gives a step-by-step workflow for building a new test suite, ending in a run, read-the-stack-trace, fix and re-run loop. It includes two worked examples, one for a plain calculator-style suite and one that uses Mockito to mock a dependency injected into a service.

It expects a Dart project, with dart test for pure Dart code or flutter test for Flutter apps. Mocking requires the mockito package and build_runner to generate mock files.

## When your agent uses it

> Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/flutter/agent-plugins/tree/HEAD/skills/dart-add-unit-test)
- [License: BSD-3-Clause](https://github.com/flutter/agent-plugins/tree/HEAD/skills/dart-add-unit-test)

## Features

- **Test file layout:** Explains how to mirror the lib folder inside test and name files with the _test.dart suffix.
- **package:test usage:** Covers grouping, test cases, expect with matchers, and async test handling.
- **Setup and teardown:** Shows how to share initialized objects across cases with setUp and tearDown callbacks.
- **Mockito mocking:** Describes generating mocks for injected dependencies and verifying calls in tests.
- **Run commands:** Lists when to use dart test versus flutter test, including integration test directories.
- **Step-by-step workflow:** Gives a checklist for creating a suite and iterating until the tests pass.

## Good for

- Write unit tests for a new Dart function or class
- Add regression tests after fixing a bug in a Flutter app
- Mock an API client and test a service that depends on it
- Organize test files to match the lib folder structure
- Set up shared test fixtures with setUp and tearDown

## Install

### Claude Code

This skill ships in the `dart-flutter` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add flutter/agent-plugins
/plugin install dart-flutter@dart-flutter
```

Or copy only this skill to `~/.claude/skills/dart-add-unit-test`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/flutter/agent-plugins.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/dart-add-unit-test &&
cp -R "$tmp/skills/dart-add-unit-test" ~/.claude/skills/dart-add-unit-test &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/dart-add-unit-test` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/dart-add-unit-test` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/flutter/agent-plugins.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/dart-add-unit-test &&
cp -R "$tmp/skills/dart-add-unit-test" ~/.agents/skills/dart-add-unit-test &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/dart-add-unit-test` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/dart-add-unit-test` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/flutter/agent-plugins.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/dart-add-unit-test &&
cp -R "$tmp/skills/dart-add-unit-test" ~/.cursor/skills/dart-add-unit-test &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/dart-add-unit-test` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/flutter/agent-plugins.git --path skills/dart-add-unit-test
```

Or copy the folder to `~/.gemini/skills/dart-add-unit-test` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/dart-add-unit-test`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/flutter/agent-plugins.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/dart-add-unit-test &&
cp -R "$tmp/skills/dart-add-unit-test" ~/.copilot/skills/dart-add-unit-test &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/dart-add-unit-test` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/flutter/agent-plugins.git
```

Then copy `agent-plugins/skills/dart-add-unit-test` into your agent's skills folder as `dart-add-unit-test`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Which test runner does Dart add unit test use?

For pure Dart projects it uses dart test, and for Flutter projects flutter test. Integration tests need the directory passed explicitly.

### Does Dart add unit test need extra packages for mocking?

Mocking examples use package:mockito with build_runner to generate mock objects.

### Where should test files go?

In the test directory at the package root, mirroring lib, with names ending in _test.dart. Integration tests go in integration_test.

### How do I install Dart add unit test in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/dart-add-unit-test to use it in all your projects, or to .claude/skills/dart-add-unit-test in one project. Or install the dart-flutter plugin, which includes it: /plugin marketplace add flutter/agent-plugins, then /plugin install dart-flutter@dart-flutter.

### Does Dart add unit test run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Dart add unit test?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Dart add unit test?

The closest alternatives to Dart add unit test are Dart generate test mocks, Flutter add widget test, Flutter testing skill, Flutter add integration test and Dart collect coverage.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Dart generate test mocks](https://ai-powered.com/skills/dart-generate-test-mocks): Dart generate test mocks is an open-source agent skill for developer tools.
- [Flutter add widget test](https://ai-powered.com/skills/flutter-add-widget-test): Flutter add widget test is an open-source agent skill for developer tools.
- [Flutter testing skill](https://ai-powered.com/skills/flutter-testing-skill): Flutter testing skill is an open-source agent skill for developer tools.
- [Flutter add integration test](https://ai-powered.com/skills/flutter-add-integration-test): Flutter add integration test is an open-source agent skill for developer tools.
- [Dart collect coverage](https://ai-powered.com/skills/dart-collect-coverage): Dart collect coverage is an open-source agent skill for developer tools.
- [Unittest skill](https://ai-powered.com/skills/unittest-skill): Unittest skill is an open-source agent skill for developer tools.
- [Dart migrate to checks package](https://ai-powered.com/skills/dart-migrate-to-checks-package): Dart migrate to checks package is an open-source agent skill for developer tools.
- [TDD](https://ai-powered.com/skills/tdd): TDD is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/dart-add-unit-test
