dart-add-unit-test
This skill helps the agent write and organize unit tests for Dart and Flutter code using the package:test library.
Identity proven by GitHub's verified organisation badge (flutter, google)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- BSD-3-Clause (permissive)
- Pin
- 0ef3972pinned Oct 9, 2026
- Context cost
- about 1,100 tokenswhen the skill loads
- GitHub stars
- 3,039on flutter/agent-plugins
- Scripts
- None found
What it does
“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.”
Generated summary from the skill's own text
This skill helps the agent write and organize unit tests for Dart and Flutter code using the package:test library. The agent creates properly structured test files mirroring the source directory, writes test cases with groups and assertions, and executes tests via dart test or flutter test commands. It covers synchronous and asynchronous testing, setup and teardown hooks, and integration with mockito for dependency injection scenarios.
When to use it
- Developing new Dart or Flutter features that need test coverage
- Fixing bugs and writing regression tests to prevent reoccurrence
- Testing functions with asynchronous operations or external dependencies
- Ensuring code quality through organized, grouped unit test suites
When not to
- Testing user interface components requiring visual inspection
- Writing tests for non-Dart languages or frameworks
- Scenarios where the code structure does not require unit test validation
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add flutter/agent-plugins --skill dart-add-unit-testInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install flutter/agent-plugins dart-add-unit-test@0ef3972f93e2baa4156ba1cbb1e515cd53079c68Installs the commit we checked (0ef3972).
Copy by hand
Download the folder at 0ef3972 and put it in .claude/skills/dart-add-unit-test for Claude Code and in .agents/skills/dart-add-unit-test for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install chrome-devtools-mcp@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Claude Code plugin
/plugin install alloydb-omni@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Claude Code plugin
/plugin install bigquery-data-analytics@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "dart-add-unit-test" by Google. Source, pinned to commit 0ef3972f93e2baa4156ba1cbb1e515cd53079c68: https://github.com/flutter/agent-plugins/tree/0ef3972f93e2baa4156ba1cbb1e515cd53079c68/skills/dart-add-unit-test 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/dart-add-unit-test/ for Claude Code and .agents/skills/dart-add-unit-test/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/google/dart-add-unit-test
SKILL.md at the pin
---
name: dart-add-unit-test
description: 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.
metadata:
model: models/gemini-3.1-pro-preview
last_modified: Mon, 03 Aug 2026 21:51:24 GMT
---
# Testing Dart and Flutter Applications
## Contents
- [Structuring Test Files](#structuring-test-files)
- [Writing Tests](#writing-tests)
- [Executing Tests](#executing-tests)
- [Test Implementation Workflow](#test-implementation-workflow)
- [Examples](#examples)
## 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.
### Task Progress
- [ ] 1. Create the test file in the `test/` directory, ensuring the `_test.dart` suffix.
- [ ] 2. Import `package:test/test.dart` and the target library.
- [ ] 3. Define a `main()` function.
- [ ] 4. Initialize shared resources or mocks using `setUp()`.
- [ ] 5. Write `test()` cases grouped by functionality using `group()`.
- [ ] 6. Execute the test suite using the appropriate CLI command.
- [ ] 7. **Feedback Loop**: Run test -> Review stack trace for failures -> Fix implementation or assertions -> Re-run until passing.
## Examples
### Standard Unit Test Suite
Demonstrates grouping, setup, synchronous, and asynchronous testing.
```dart
import 'package:test/test.dart';
import 'package:my_package/calculator.dart';
void main() {
group('Calculator', () {
late Calculator calc;
setUp(() {
calc = Calculator();
});
test('adds two numbers correctly', () {
expect(calc.add(2, 3), equals(5));
});
test('handles asynchronous operations', () async {
final result = await calc.fetchRemoteValue();
expect(result, isNotNull);
expect(result, greaterThan(0));
});
});
}
```
### Mocking with Mockito
Demonstrates configuring a mock object for dependency injection testing.
```dart
import 'package:test/test.dart';
import 'package:mockito/mockito.dart';
import 'package:mockito/annotations.dart';
import 'package:my_package/api_client.dart';
import 'package:my_package/data_service.dart';
// Generate the mock using build_runner: dart run build_runner build
@GenerateNiceMocks([MockSpec<ApiClient>()])
import 'data_service_test.mocks.dart';
void main() {
group('DataService', () {
late MockApiClient mockApiClient;
late DataService dataService;
setUp(() {
mockApiClient = MockApiClient();
dataService = DataService(apiClient: mockApiClient);
});
test('returns parsed data on successful API call', () async {
// Configure the mock
when(mockApiClient.get('/data')).thenAnswer((_) async => '{"id": 1}');
// Execute the system under test
final result = await dataService.fetchData();
// Verify outcomes and interactions
expect(result.id, equals(1));
verify(mockApiClient.get('/data')).called(1);
});
});
}
```
From flutter/agent-plugins at 0ef3972, shown as plain text under its license: BSD-3-Clause (permissive). The license text is in LICENSE.
View SKILL.md on GitHub at 0ef3972Files
- SKILL.md4.7 KB · 02428fa20c2c
1 file, 4.7 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at 0ef3972More from Google
skill-creator
This skill guides agents through creating new skills that extend Gemini CLI with specialized knowledge, workflows, and tool integrations.
Contains scripts
Gemini CLI · about 5K tokens · pinned 6 days ago
chrome-devtools-cli
This skill enables agents to automate browser interactions and inspect web pages using Chrome DevTools via command-line interface.
Claude Code, Codex, Cursor +4 · about 2.9K tokens · pinned 6 days ago
cloud-run-basics
Deploys and manages Google Cloud Run services, jobs, and worker pools for running containerized applications or source code.
Claude Code, Codex, Cursor +4 · about 3.9K tokens · pinned 6 days ago
retail-virtual-tryon
Creates virtual try-on agents on Google Cloud using Gemini image models and Veo video generation, supporting static image try-ons and catwalk animations.
Contains scripts
Claude Code, Codex, Cursor +3 · about 3.3K tokens · pinned 6 days ago
site-md
This skill analyzes project briefs and generates a .stitch/SITE.md constitution file that documents the project's identity, visual direction, architecture…
Claude Code, Codex, Cursor +4 · about 730 tokens · pinned 6 days ago
stitch::code-to-design
This skill converts existing frontend code (React, Vue, Angular, etc.) into a Stitch Design by extracting HTML, analyzing design systems, and uploading both…
Claude Code, Codex, Cursor +4 · about 760 tokens · pinned 6 days ago
Related in Testing and QA
next-partial-prefetching-optimizer
This skill optimizes Next.js client-side navigation under Partial Prefetching by defining what UI loads before and after a click.
by VercelOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.8K tokens · pinned 6 days ago
Invalid--Name
This skill cannot be described because its name format is invalid and no functional description or instructions are provided in the skill metadata.
by CrewAIOfficial publisher
Claude Code, Codex, Cursor +4 · about 0 tokens · pinned 6 days ago
triaging-visual-review-runs
Inspects PostHog Visual Review screenshot regression runs that gate pull requests, helping engineers triage diff results, identify flaky stories, and decide…
by PostHogOfficial publisher
Claude Code, Codex, Cursor +4 · about 8.9K tokens · pinned 6 days ago
code-change-verification
Runs formatting, linting, type checking, and test verification for SDK code changes after review.
by OpenAIOfficial publisher
Contains scripts
Codex · about 1.3K tokens · pinned 6 days ago
runtime-behavior-probe
This skill guides agents to plan and execute controlled runtime investigations with explicit user approval before each probe runs.
by OpenAIOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 3.8K tokens · pinned 6 days ago
test-coverage-improver
This skill measures Python SDK test coverage using coverage artifacts and identifies gaps in caller-visible behavior testing.
by OpenAIOfficial publisher
Claude Code, Codex, Cursor +4 · about 640 tokens · pinned 6 days ago
Open roles at Google
No open roles at Google on the Agent Native jobs board right now.
Browse the jobs board