# dart-add-unit-test

> Claude/Codex skill by [@flutter](https://omgskills.com/library/flutter/index.md) · 3.1k stars · Updated 2026-10-17

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.

## Install

```sh
git clone https://github.com/flutter/agent-plugins /tmp/agent-plugins && ln -s /tmp/agent-plugins/skills/dart-add-unit-test ~/.claude/skills/dart-add-unit-test
```

## From README

Testing Dart and Flutter Applications Contents Structuring Test Files Writing Tests Executing Tests Test Implementation Workflow 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/utilstest.dart). If writing integration tests, place them in an integrationtest 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:fluttertest/fluttertest.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()).

## Links

- HTML page: https://omgskills.com/library/flutter/agent-plugins/dart-add-unit-test/
- GitHub: https://github.com/flutter/agent-plugins
- Author: [@flutter](https://omgskills.com/library/flutter/index.md)

## More skills by this author

- [dart-log-failure-parser](https://omgskills.com/library/flutter/flutter/dart-log-failure-parser/index.md) — Parse failures from Dart and Flutter test logs.
   - [@flutter](https://omgskills.com/library/flutter/index.md) · 181k stars
- [run-devicelab-with-led](https://omgskills.com/library/flutter/flutter/dot-agents/skills/run-devicelab-with-led/index.md) — Used to run DeviceLab tests for Flutter PRs using LUCI's \`led\` CLI tool.
   - [@flutter](https://omgskills.com/library/flutter/index.md) · 181k stars
- [find-release](https://omgskills.com/library/flutter/flutter/find-release/index.md) — A skill to find the lowest Dart and Flutter release containing a given commit.
   - [@flutter](https://omgskills.com/library/flutter/index.md) · 180k stars
