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.
npx skills add sutchan/Agent-Skills-Hub --skill dart-generate-test-mocksgit clone --depth 1 https://github.com/sutchan/Agent-Skills-HubWrote 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.
[](https://agentmods.dev/skills/sutchan/agent-skills-hub/dart-generate-test-mocks)<a href="https://agentmods.dev/skills/sutchan/agent-skills-hub/dart-generate-test-mocks"><img src="https://agentmods.dev/badge/skills/sutchan/agent-skills-hub/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.
<a href="https://agentmods.dev/skills/sutchan/agent-skills-hub/dart-generate-test-mocks"><img src="https://agentmods.dev/badge/skills/sutchan/agent-skills-hub/dart-generate-test-mocks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00043 | $0.01468 |
| Opus 5 | $0.00022 | $0.00734 |
| Sonnet 5 | $0.00009 | $0.00294 |
| Haiku 4.5 | $0.00004 | $0.00147 |
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 yesterday.
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.
This is a copy
91% identical to dart-generate-test-mocks — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
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
- Managing Dependencies
- Generating Mocks
- Implementing Unit Tests
- Workflow: Creating and Running Mocked Tests
- Examples
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
Uriobjects usingUri.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) usingdart 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
@GenerateNiceMocksannotation (preferable to@GenerateMocksto 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.dartextension. - Execute
build_runnerto 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 aFutureorStream. Never usethenReturnfor asynchronous returns.
- Use
- 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, orcaptureAnyfor flexible verification.
- Use
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.
- yesterday Changed · -4 lines · +16 tokens per session ca58b0e0d045
- 7d ago First seen · 160 lines · 27 tokens per session scan A a65d591673cb
dart-generate-test-mocks is a skill published in the GitHub repository sutchan/Agent-Skills-Hub (2 stars, last pushed yesterday), licensed MIT. It adds 43 tokens to every session and 1,468 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. It is 91% identical to dart-generate-test-mocks, differing in 0 lines, and is treated as a copy.
Other skills, from other repositories
tdd-workflow
Runs the full TDD workflow for a TypeScript/JavaScript feature — user journeys to test cases, unit tests (Jest/Vitest + Testing Library), API/integration tests, Playwright E2E, and a coverage gate wired into CI. Use when building a Next.js/React/Node feature end to end, not just a single unit test, or when asked to…
migrate-xunit-to-xunit-v3
Migrate .NET test projects from xUnit.net v2 to xunit.v3 and fix v3 breaks. Use for package/CPM conversion, OutputType=Exe, preserving the VSTest or MTP runner (including projects currently using YTest.MTP.XUnit2), incompatible TFMs, async void tests, string-to-Type attributes, custom Fact/Theory/BeforeAfterTest…
test-harness
Generates pytest test suites with happy path, edge cases, error conditions, fixture scaffolding, mocks, async patterns. Triggers on: "generate tests", "write tests for", "test this function", "create test suite", "pytest for", "unit tests for", "mock strategy for".
unit-test-mapper-converter
Provides patterns for unit testing mappers, converters, and bean mappings. Validates entity-to-DTO and model transformation logic in isolation. Generates executable mapping tests with MapStruct and custom converter test coverage. Use when writing mapping tests, converter tests, entity mapping tests, or ensuring…
unit-test-parameterized
Provides parameterized testing patterns with JUnit 5, generates data-driven unit tests using @ParameterizedTest, @ValueSource, @CsvSource, @MethodSource. Creates tests that run the same logic with multiple input values. Use when writing data-driven Java tests, multiple test cases from single method, or boundary value…
unit-test-scheduled-async
Provides patterns for unit testing Spring @Scheduled and @Async methods using JUnit 5, CompletableFuture, Awaitility, and Mockito. Covers mocking task execution and timing, verifying execution counts, testing cron expressions, validating retry behavior, and simulating thread pool behavior. Use when testing background…