mockito

mockito is a skill for Claude Code from evanca/flutter-ai-rules. It costs 32 tokens per session (857 once invoked), scanned A, original, MIT.

A guide for using Mockito, a Dart and Flutter library that creates test doubles such as mocks and fakes. It covers generated mocks, method stubbing, interaction checks, and choosing real objects when they are sufficient.

In plain words
What is it for?
Use it when writing tests that need simulated services, configured return values, call-count or argument checks, generated mock classes, or advice on choosing between real objects, fakes, and mocks.
Why use it?
It helps tests isolate the code under test without mocking data models or testing the mock itself. It also avoids common setup and code-generation mistakes.

Skill for Claude Code

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

Part of the flutter-ai-skills plugin — 37 skills shipped together

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.

agentmods
npx agentmods add skills/evanca/flutter-ai-rules/mockito
Any agent
npx skills add evanca/flutter-ai-rules --skill mockito
Clone the repo
git clone --depth 1 https://github.com/evanca/flutter-ai-rules

Made for: Claude Code.

Or install flutter-ai-skills, the plugin that ships this one along with the rest of its 37 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 mockito

README.md
[![agentmods](https://agentmods.dev/badge/skills/evanca/flutter-ai-rules/mockito.svg)](https://agentmods.dev/skills/evanca/flutter-ai-rules/mockito)
Your own site
<a href="https://agentmods.dev/skills/evanca/flutter-ai-rules/mockito"><img src="https://agentmods.dev/badge/skills/evanca/flutter-ai-rules/mockito.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 857 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
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.00032 $0.00857
Opus 5 $0.00016 $0.00428
Sonnet 5 $0.00006 $0.00171
Haiku 4.5 $0.00003 $0.00086

Measured 6d ago against content hash 1c50c248c119, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

mockito scanned grade A with 1 finding 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 6d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

when(mock.fetch(any, headers: any)).thenReturn(response);
skills/mockito/SKILL.md · 147 lines

How it starts

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

Mockito Skill

This skill defines how to correctly use the mockito package for mocking in Dart and Flutter tests.


1. Mock vs. Fake vs. Real Object

Use When
Real object Prefer over mocks when practical.
Fake (extends Fake) Lightweight custom implementation; override only the methods you need. Prefer over mocks when you don't need interaction verification.
Mock (extends Mock) Only when you need to verify interactions (call counts, arguments) or stub dynamic responses.
  • Data models should not be mocked if they can be constructed with stubbed data.
  • Only use mocks if your test has verify assertions; otherwise prefer real or fake objects.

2. Generating Mocks

@GenerateMocks([MyClass])
// or for nice mocks (return simple legal values for missing stubs):
@GenerateNiceMocks([MockSpec<MyClass>()])
void main() { ... }
dart run build_runner build
  • Only annotate files under test/ for mock generation by default.
  • Use a build.yaml if you need to generate mocks outside of test/.
  • Never add @override methods or implementations to a class extending Mock.
  • Never stub responses in a mock's constructor or inside the mock class — always stub in your tests.

3. Stubbing

final mock = MockCat();

// Return a value
when(mock.sound()).thenReturn('Meow');

// Throw an error
when(mock.sound()).thenThrow(Exception('No sound'));

// Calculate response at call time
when(mock.sound()).thenAnswer((_) => computedValue);

// Return values in sequence
when(mock.sound()).thenReturnInOrder(['Meow', 'Purr']);
  • Always stub methods/getters before using them if you need specific return values.
  • Missing stub behavior: @GenerateMocks → throws; @GenerateNiceMocks → returns a simple legal value.
  • Use throwOnMissingStub(mock) to throw on any unstubbed call.

4. Verification

verify(mock.sound());                  // called at least once
verifyNever(mock.eat(any));            // never called
verify(mock.sound()).called(2);        // called exactly twice

Read the full file on GitHub · 147 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. 6d ago First seen · 147 lines · 32 tokens per session scan A 1c50c248c119

Subscribe to this mod's changes

mockito is a skill published in the GitHub repository evanca/flutter-ai-rules (632 stars, last pushed 5d ago), licensed MIT. It adds 32 tokens to every session and 857 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

dart-expert

Expert-level Dart, Flutter, mobile development, and cross-platform apps. Use when the user mentions Flutter, mobile, cross platform, or widgets, or when the task involves Dart Language or Flutter Framework.

personamanagmentlayer/pcl · 44 tokens

Sanad Client Tester

Comprehensive testing and interactive verification protocol for the Sanad Flutter client including unit, widget, E2E, and agent-driven UI testing through the Dart VM Service.

EastStarAI/sanad-agent · 38 tokens

component-creation

Step-by-step workflow for creating accessible, tested UI components. Use when the user asks to create a new UI component.

girijashankarj/cursor-handbook · 28 tokens

dart-sdk-changelog

Expert guide and lookup reference for the Dart SDK CHANGELOG, version history, experimental features, macros, and augmentations from Dart 1.x to modern Dart 3.x. Use this skill whenever the user asks "what's new in Dart X", "what's new in 3.13", "what's new in 3.12", asks how to find the minimum SDK version (minSdk)…

RandalSchwartz/dart-sdk-skills · 147 tokens

flutter-sdk-changelog

Expert guide and lookup reference for Flutter framework versions, widget deprecations, API replacements, Material 3 migrations, and the unbundling of standalone materialui and cupertinoui packages from Flutter 1.0 to modern Flutter (3.44+ / 3.47+). Use this skill whenever the user asks "what's new in Flutter X"…

RandalSchwartz/dart-sdk-skills · 186 tokens

iterate-agent-harness

Turn an agent failure—premature stop, false completion, gamed check, missed file, broken handoff—into a durable rule/skill/hook/CI guard plus regression test. Use when "the agent stopped early again", "it gamed the test", or "add a guard so this doesn't recur". App bugs → workflow-fix-and-ship.

kensaurus/cursor-kenji · 79 tokens