dart-add-unit-test

Write Dart and Flutter unit tests with package:test and Mockito.

428|29|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/dart-lang/skills --skill dart-add-unit-test
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dart-add-unit-test
Source: https://github.com/dart-lang/skills/tree/main/skills/dart-add-unit-test
Command: npx skills add https://github.com/dart-lang/skills --skill dart-add-unit-test

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enable developers to validate Dart and Flutter code correctness through well-structured unit tests.

Core Features & Use Cases

  • Structure tests to mirror lib/test organization to improve discoverability.
  • Use group to organize related tests, setUp and tearDown for shared state, and expect for assertions.
  • Integrate with Mockito for mocking and defining expectations in tests; supports async tests and integration with flutter_test when needed.

Quick Start

Create a test file under test/ that mirrors your lib/ directory, then run dart test to execute the suite.

Frequently Asked Questions about dart-add-unit-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure unit tests for a Dart project?▼

Structure Dart unit tests by creating files under the test/ directory that mirror your lib/ organization to improve discoverability. Use group to organize related tests, setUp and tearDown for shared state, and expect for assertions.

Can I use Mockito for mocking dependencies in Flutter unit tests?▼

Yes, you can integrate Mockito for mocking dependencies and defining expectations in Flutter unit tests. This Skill supports mocked scenarios, allowing you to isolate components and validate behavior using package:test.

Does this approach support asynchronous Dart code testing?▼

Yes, this unit testing approach fully supports asynchronous Dart code testing. You can validate synchronous, asynchronous, and mocked scenarios across pure Dart and Flutter projects using package:test.

What is the best way to organize related Dart tests using package:test?▼

The best way to organize related Dart tests is using the group function provided by package:test. Combine this with setUp and tearDown methods to manage shared state and ensure clean, well-structured test suites.

How do I run a Dart unit test suite after organizing the files?▼

After organizing your files under the test/ directory to mirror your lib/ structure, run the dart test command to execute your entire Dart unit test suite and validate code correctness.