
dart-generate-test-mocks
Define and generate mock objects for external dependencies
by dart-langFree
Description
dart-generate-test-mocks is an agent skill from the Dart team's skills collection, listed on skills.sh. It helps an AI agent define and generate mock objects for external dependencies, using package:mockito and build_runner. It applies when you are unit testing a class that depends on something complex, such as an API client or a database. The skill's design advice is to structure code for testability: inject external services such as an http.Client through constructors, isolate complex dependencies behind clear interfaces, use Uri objects rather than raw strings for URLs, and use Dart's classes and mixins to define those interfaces. The skill then covers managing dependencies, generating mocks with build_runner, implementing unit tests, and a workflow for creating and running mocked tests, with examples. Replacing real services with mocks keeps tests fast and repeatable. A skill is a SKILL.md file of instructions, sometimes with scripts and reference notes, that an AI agent loads only when a task calls for it. The skill is listed as free on skills.sh.…
Highlights
- Generates mocks with mockito and build_runner
- Constructor injection guidance
- Interfaces for external services
- Workflow for mocked unit tests
Ratings & Reviews
No ratings yet
Be the first to rate dart-generate-test-mocks.
People also visit

dart-migrate-to-checks-package
Replace the usage of `expect` and similar functions from `package:matcher`
dart-generate-test-mocks FAQ
What does the dart-generate-test-mocks skill do?
It helps an AI agent define and generate mock objects for a Dart class's external dependencies for unit tests.
How do I install it?
Run: npx skills add https://github.com/dart-lang/skills --skill dart-generate-test-mocks
Is it free?
Yes. The skill is listed as free on skills.sh.
Which tools does it use?
package:mockito for mocks and build_runner to generate them.
How should my code be structured?
The skill says to inject external services through constructors and define clear interfaces, so they can be replaced by mocks.
What are the best dart-generate-test-mocks alternatives?
Popular alternatives to dart-generate-test-mocks include dart-add-unit-test, unit-test-service-layer and flutter-testing-apps. See all dart-generate-test-mocks alternatives












