dart-generate-test-mocks

dart-generate-test-mocks is a skill for Claude Code from flutter/agent-plugins. It costs 43 tokens per session (1,468 once invoked), scanned A, original, BSD-3-Clause.

A Dart testing guide for creating mock objects with Mockito and build_runner. A mock is a controlled stand-in for an external service such as an API or database.

In plain words
What is it for?
Use it to structure classes for dependency injection, configure testing packages, generate mocks, and write tests for code that calls external services.
Why use it?
It lets unit tests check your own code without depending on real network services, databases, or other complex systems.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the dart-flutter plugin — 31 skills shipped together

Good fit Use it to structure classes for dependency injection, configure testing packages, generate mocks, and write tests for code that calls external services.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/flutter/agent-plugins/dart-generate-test-mocks
About the project

Flutter Agent Plugins is a collection maintained by the Flutter team that extends coding agents with Flutter-specific skills, rules, MCP configuration, and bundled workflows. Flutter developers use it to help agents perform tasks such as testing and building widget previews. The catalogue entries are components of these agent plugins.

flutter/agent-plugins · 3,222 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add flutter/agent-plugins --skill dart-generate-test-mocks
Clone the repo
git clone --depth 1 https://github.com/flutter/agent-plugins

Made for: Claude Code.

Or install dart-flutter, the plugin that ships this one along with the rest of its 31 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dart-generate-test-mocks

README.md
[![agentmods](https://agentmods.dev/badge/skills/flutter/agent-plugins/dart-generate-test-mocks/github.svg)](https://agentmods.dev/skills/flutter/agent-plugins/dart-generate-test-mocks)
Your own site
<a href="https://agentmods.dev/skills/flutter/agent-plugins/dart-generate-test-mocks"><img src="https://agentmods.dev/badge/skills/flutter/agent-plugins/dart-generate-test-mocks/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dart-generate-test-mocks

Your own site · 80×15
<a href="https://agentmods.dev/skills/flutter/agent-plugins/dart-generate-test-mocks"><img src="https://agentmods.dev/badge/skills/flutter/agent-plugins/dart-generate-test-mocks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,468 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 14 Jul 2026
  • Snyk pass 14 Jul 2026
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 3 findings, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Data Exfiltration · line 132
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 138
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 149
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00043 $0.01468
Opus 5.5 $0.00017 $0.00587
Sonnet 5.5 $0.00009 $0.00294
Haiku 4.5 $0.00004 $0.00147

Measured 3mo ago against content hash ca58b0e0d045, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

dart-generate-test-mocks scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

2 near-identical copies found in the catalogue:

skills/dart-generate-test-mocks/SKILL.md · 156 lines

How it starts

The opening of the file, as written. The whole thing — 156 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testing and Mocking Dart Applications

Contents

Structuring Code for Testability

Design Dart classes to support dependency injection. Isolate complex external dependencies (like API clients or databases) so they can be replaced with mock objects during testing.

  • Inject external services (e.g., http.Client) through class constructors.
  • Represent URLs strictly as Uri objects using Uri.parse(string).
  • Utilize Dart's object-oriented features (classes, mixins) to define clear interfaces for external interactions.

Managing Dependencies

Configure the pubspec.yaml file with the necessary testing and code generation packages.

  • Add runtime dependencies (e.g., package:http) using dart pub add http.
  • Add testing dependencies using dart pub add dev:test dev:mockito dev:build_runner.
  • Import HTTP libraries with a prefix to avoid namespace collisions: import 'package:http/http.dart' as http;.

Generating Mocks

Use package:mockito and build_runner to automatically generate mock classes for fixed scenarios and behavior verification.

  • Always use the @GenerateNiceMocks annotation (preferable to @GenerateMocks to avoid missing stub exceptions).
  • Place the annotation in the test file, passing a list of MockSpec<Type>() objects.
  • Import the generated file using the .mocks.dart extension.
  • Execute build_runner to generate the mock files: dart run build_runner build.

Implementing Unit Tests

Isolate the system under test using the generated mock objects. Use package:test to structure the test suite.

  • Stubbing: Configure mock behavior before interacting with the system under test.
    • Use when(mock.method()).thenReturn(value) for synchronous methods.
    • CRITICAL: Always use thenAnswer((_) async => value) for methods returning a Future or Stream. Never use thenReturn for asynchronous returns.
  • Verification: Assert that the system under test interacted with the mock object correctly.
    • Use verify(mock.method()).called(1) to check exact invocation counts.
    • Use argument matchers like any, anyNamed, or captureAny for flexible verification.

Read the full file on GitHub · 156 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 156 lines · 43 tokens per session scan A ca58b0e0d045

Subscribe to this mod's changes

dart-generate-test-mocks is a skill published in the GitHub repository flutter/agent-plugins (3,222 stars, last pushed 11d ago), licensed BSD-3-Clause. It adds 43 tokens to every session and 1,468 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

dart-generate-test-mocks compared with skills from other repositories

dart-generate-test-mocks next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
dart-generate-test-mocksflutter/agent-pluginsSkill3.2k11d agoBSD-3-ClauseA43Claude Code
test-masterJeffallan/claude-skillsSkill13ktodayMITA104Claude Code
migrate-xunit-to-xunit-v3dotnet/skillsSkill6.4ktodayMITA149Claude Code
go-testingGentleman-Programming/gentle-aiSkill9.7kyesterdayMITA26Claude Code, Codex
dart-testdartsim/dartSkill1.2ktodayBSD-2-ClauseA18Claude Code, Codex
test-generatorrshankras/claude-code-apple-skillsSkill91521d agoMITA33Claude Code
nw-fp-clojurenWave-ai/nWaveSkill63611d agoMITA25Claude Code