dart-add-unit-test
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
Install this Claude and Codex skill with the command below. The command stays visible even when copy support is unavailable.
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()).