Agent skill

Mock Call Count Retry Fallback

by divinevideo in divinevideo/divine-mobile

Fix test failures when adding retry/fallback logic causes mock call count mismatches.

MPL-2.0Auto-check passedMobile

Install Mock Call Count Retry Fallback

skills CLI
$ npx skills add divinevideo/divine-mobile --skill mock-call-count-retry-fallback -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install divinevideo/divine-mobile mock-call-count-retry-fallback --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/mock-call-count-retry-fallback .claude/skills/mock-call-count-retry-fallback && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mock-call-count-retry-fallback
GitHub stars
266
Token cost
~1.2k tokens
SKILL.md length
362 words
Files
1
Skills in repo
103
Repo updated
First seen
Licence
MPL-2.0

At a glance

Fix test failures when adding retry/fallback logic causes mock call count mismatches.

  • Works in 4 steps: Identify the New Code Paths → Mock New Dependencies → Update Expected Call Counts → …
  • Test fails with Expected: <1
  • SKILL.md covers Problem, Context / Trigger Conditions, Solution and Verification, plus 4 more sections
  • Calls flutter

What it does

Mock Call Count Retry Fallback is an agent skill from divinevideo/divine-mobile. Fix test failures when adding retry/fallback logic causes mock call count mismatches. Use when: (1) Test fails with "Expected: <1, Actual: <2" or similar call count errors after adding retry or fallback mechanisms, (2) MissingStubError appears for methods in new fallback code paths, (3) Mockito verify().called(N) assertions fail after behavior changes. Applies to Dart/Flutter with Mockito, but pattern is universal.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile, covering Cross-platform mobile apps and Failing and flaky tests. It works with Flutter and Dart. The licence is MPL-2.0.

When your agent uses it

  • Test fails with Expected: <1
  • Similar call count errors after adding retry
  • Fallback mechanisms
  • MissingStubError appears for methods in new fallback code paths

Example prompts

  • “Expected: <1, Actual: <2”
  • “/mock-call-count-retry-fallback”

Requirements

  • Python 3

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Identify the New Code Paths
  2. Mock New Dependencies
  3. Update Expected Call Counts
  4. Add Comments Explaining the Count

What it can do on your machine

Read from SKILL.md and the folder at commit 6487b05. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • flutter

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • pub.dev
    • docs.flutter.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Mock Call Count Retry Fallback loads about 1.2k tokens when it runs. Until then it costs about 113 tokens; SKILL.md has 362 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~113
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from divinevideo/divine-mobile at commit 6487b05, republished under its MPL-2.0 licence (© divinevideo). 362 words, ~1,217 tokens.

Download SKILL.mdSave it as .claude/skills/mock-call-count-retry-fallback/SKILL.md (or your agent's skills folder).
name
mock-call-count-retry-fallback
description
Fix test failures when adding retry/fallback logic causes mock call count mismatches. Use when: (1) Test fails with "Expected: <1>, Actual: <2>" or similar call count errors after adding retry or fallback mechanisms, (2) MissingStubError appears for methods in new fallback code paths, (3) Mockito verify().called(N) assertions fail after behavior changes. Applies to Dart/Flutter with Mockito, but pattern is universal.
author
Claude Code
version
1.0.0
date
2026-02-01

Mock Call Count Failures After Adding Retry/Fallback Logic

Problem

When you add retry logic, fallback mechanisms, or alternative code paths to a service, existing tests that verify exact mock method call counts will fail. The tests were written for the original behavior and don't account for the new retry/fallback calls.

Context / Trigger Conditions

  • Test fails with: Expected: <N>, Actual: <M> where M > N
  • Error message: "Unexpected number of calls"
  • MissingStubError: 'methodName' No stub was found which matches the arguments
  • You recently added:
    • Retry logic (e.g., retry after timeout)
    • Fallback mechanisms (e.g., try primary server, fall back to secondary)
    • Alternative code paths (e.g., try REST API, fall back to WebSocket)
  • The failing test uses verify(...).called(N) assertions

Solution

Step 1: Identify the New Code Paths

Trace through your new retry/fallback logic to understand:

  • How many times the mocked method will now be called
  • What new methods are being called that weren't before
Step 2: Mock New Dependencies

If your fallback code calls methods that weren't previously mocked:

dart
// BEFORE: Only mocked the primary method
when(mockService.primaryMethod(any)).thenAnswer((_) async => 'result');

// AFTER: Also mock fallback-related methods
when(mockService.primaryMethod(any)).thenAnswer((_) async => 'result');
when(mockService.addFallbackServer(any)).thenAnswer((_) async => false);  // Graceful failure
when(mockService.queryFallback(any)).thenAnswer((_) async => []);
Step 3: Update Expected Call Counts
dart
// BEFORE: Expected single call
verify(mockService.createSubscription(...)).called(1);

// AFTER: Expected calls = initial + retries
// Document WHY the count changed
verify(mockService.createSubscription(...)).called(2);  // initial + retry after fallback
Step 4: Add Comments Explaining the Count
dart
// Verify subscription was created
// Note: With the indexer fallback logic, createSubscription is called twice:
// 1. First attempt via main relay batch fetch
// 2. Retry attempt after indexer fallback fails
verify(
  mockService.createSubscription(...),
).called(2);

Verification

  1. Run the specific test: flutter test --name "test name"
  2. Verify the test passes
  3. Verify the service's actual behavior matches the expected retry count
Show full SKILL.md (157 more words)Show less

Example

Scenario: Added indexer relay fallback to profile fetching

Original behavior:

  • Fetch profile from main relay → 1 subscription created

New behavior:

  1. Fetch profile from main relay (subscription #1)
  2. If not found, try indexer relays
  3. If indexers fail, retry main relay (subscription #2)
  4. After 2 failures, mark profile as missing

Test fix:

dart
test('should force refresh profile with forceRefresh parameter', () async {
  // Setup mock subscription manager
  when(
    mockSubscriptionManager.createSubscription(...),
  ).thenAnswer((_) async => 'sub_123');

  // Mock addRelay to return false (indexer relays not available)
  // This prevents MissingStubError and simulates unavailable indexers
  when(mockNostrService.addRelay(any)).thenAnswer((_) async => false);

  // ... test setup ...

  await service.fetchProfile(pubkey, forceRefresh: true);

  // Expect 2 calls: initial attempt + retry after indexer fallback
  verify(
    mockSubscriptionManager.createSubscription(...),
  ).called(2);
});

Notes

  • Don't just change the number: Always understand WHY the count changed
  • Mock fallback paths to fail gracefully: Return false/empty instead of throwing
  • Consider test isolation: Some tests may need different mock setups for different scenarios
  • Document behavior changes: Future maintainers need to understand the expected flow
  • This pattern applies universally: Java Mockito, Python unittest.mock, Jest, etc.
  • When adding caching: methods may be called 0 times on cache hit
  • When adding circuit breakers: methods may be called fewer times on open circuit
  • When adding rate limiting: methods may be delayed or batched

References

© divinevideo, MPL-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/mock-call-count-retry-fallback of divinevideo/divine-mobile.

Open the folder on GitHubat commit 6487b05

Compare with similar skills

Mock Call Count Retry Fallback next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mock Call Count Retry Fallback compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mock Call Count Retry Fallback this skilldivinevideo/divine-mobile266—~1.2kAutomated safety check: PassMPL-2.0
Green GateVeryGoodOpenSource/vgv-ai-flutter-plugin170—~4.7kAutomated safety check: NotesMIT
Analyze GitHub Flakeflutter/flutter179k—~1.1kAutomated safety check: PassBSD-3-Clause
Flutter TestingMADTeacher/mad-agents-skills110—~1.5kAutomated safety check: PassMIT
Testingevanca/flutter-ai-rules650—~1.1kAutomated safety check: PassMIT
Test Guidelinesgetsentry/sentry-dart873—~3.1kAutomated safety check: PassMIT

Similar skills

  • Green Gate

    VeryGoodOpenSource/vgv-ai-flutter-plugin

    Drives a Dart or Flutter package fully green through a verify-fix-rerun loop across four gates: analyze, format, test, coverage.

    170 GitHub stars~4.7k tokensUpdated 3 days ago
    MobileAuto-check: notes
  • Analyze GitHub Flake

    flutter/flutter

    Expertise in analyzing flake github issues in the flutter/flutter repository.

    179k GitHub stars~1.1k tokensUpdated today
    MobileAuto-check passed
  • Flutter Testing

    MADTeacher/mad-agents-skills

    Write, fix, review, debug, and validate Flutter tests for apps, packages, and plugins.

    110 GitHub stars~1.5k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed
  • Testing

    evanca/flutter-ai-rules

    A skill your agent uses when writing or reviewing Flutter/Dart tests (unit, widget, golden), fixing flaky tests, adding coverage, or choosing between unit and widget tests.

    650 GitHub stars~1.1k tokensUpdated 25 days ago
    Testing & QAAuto-check passed
  • Test Guidelines

    getsentry/sentry-dart

    Official

    Enforce Sentry Dart/Flutter SDK test conventions for naming, structure, and fixtures.

    873 GitHub stars~3.1k tokensUpdated today
    Testing & QAAuto-check passed
  • Bloc

    VeryGoodOpenSource/vgv-ai-flutter-plugin

    Best practices for Bloc state management in Flutter/Dart, covering Cubit versus Bloc, event and state naming, sealed classes with Equatable, the Page/View split with BlocProvider, BlocBuilder…

    170 GitHub stars~2k tokensUpdated 3 days ago
    MobileAuto-check passed

More from divinevideo/divine-mobile

All 103 skills in this repo
  • Fix ArgoCD ExternalSecret deployment failing with "namespace X is not permitted in project Y".

    266 GitHub stars~931 tokensUpdated today
    Auto-check passed
  • Art Direct

    divinevideo/divine-mobile

    Art direction for any content — reads text, PDF, Word, HTML, PPT, then proposes 2-3 creative directions with photography style, mood, and visual language.

    266 GitHub stars~4.8k tokensUpdated today
    Auto-check passed
  • Async Await Null Race Condition

    divinevideo/divine-mobile

    Fix "Null check operator used on a null value" errors when an object is set to null during an async await.

    266 GitHub stars~881 tokensUpdated today
    Auto-check passed
  • AWS V4 Signing Custom Headers Gcs

    divinevideo/divine-mobile

    Add custom metadata headers (x-amz-meta-) to AWS v4 signed requests for GCS S3-compatible API.

    266 GitHub stars~1k tokensUpdated today
    Auto-check passed
  • Bash Herestring Newline Secrets

    divinevideo/divine-mobile

    Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings.

    266 GitHub stars~791 tokensUpdated today
    Auto-check passed
  • Fix silent video/media processing failures caused by URL extraction code that filters on file extensions (.mp4, .webm, .webp).

    266 GitHub stars~1.1k tokensUpdated today
    Auto-check passed

Works with

Questions about Mock Call Count Retry Fallback

What does Mock Call Count Retry Fallback do?

Fix test failures when adding retry/fallback logic causes mock call count mismatches. Mock Call Count Retry Fallback is an agent skill from divinevideo/divine-mobile. Fix test failures when adding retry/fallback logic causes mock call count mismatches.

When should I use Mock Call Count Retry Fallback?

Mock Call Count Retry Fallback fits situations like: test fails with Expected: <1; similar call count errors after adding retry; fallback mechanisms; missingStubError appears for methods in new fallback code paths.

How do I install Mock Call Count Retry Fallback in Claude Code?

Run `npx skills add divinevideo/divine-mobile --skill mock-call-count-retry-fallback -a claude-code`. Or copy the skill folder (.agents/skills/mock-call-count-retry-fallback in divinevideo/divine-mobile) into .claude/skills/mock-call-count-retry-fallback in your project. Claude Code loads it when a task matches its description.

How do I install Mock Call Count Retry Fallback in Codex?

Run `npx skills add divinevideo/divine-mobile --skill mock-call-count-retry-fallback -a codex`. Or copy the skill folder (.agents/skills/mock-call-count-retry-fallback in divinevideo/divine-mobile) into .agents/skills/mock-call-count-retry-fallback in your project. Codex loads it when a task matches its description.

Can I use Mock Call Count Retry Fallback in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add divinevideo/divine-mobile --skill mock-call-count-retry-fallback -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mock-call-count-retry-fallback, .gemini/skills/mock-call-count-retry-fallback, .github/skills/mock-call-count-retry-fallback and .opencode/skills/mock-call-count-retry-fallback in your project.

What does Mock Call Count Retry Fallback need to run?

Going by SKILL.md and its folder, Mock Call Count Retry Fallback needs the command-line tools its instructions call (flutter). Our summary lists: Python 3.

Does Mock Call Count Retry Fallback access the network?

SKILL.md names 2 domains. As links in the text: pub.dev and docs.flutter.dev. This is read from the text; nothing was executed.

Is Mock Call Count Retry Fallback safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Mock Call Count Retry Fallback use?

Mock Call Count Retry Fallback is published under the MPL-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mock Call Count Retry Fallback use?

About 1.2k tokens (SKILL.md is roughly 4.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Mock Call Count Retry Fallback?

Skills that share tags, products or a category with Mock Call Count Retry Fallback: Green Gate (VeryGoodOpenSource/vgv-ai-flutter-plugin, 170 stars), Analyze GitHub Flake (flutter/flutter, 179k stars), Flutter Testing (MADTeacher/mad-agents-skills, 110 stars) and Testing (evanca/flutter-ai-rules, 650 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mock Call Count Retry Fallback?

divinevideo (a GitHub organization) maintains it in divinevideo/divine-mobile, which has 266 GitHub stars. The repository holds 103 skills in this directory. The repository was last updated on October 9, 2026.

Source: divinevideo/divine-mobile on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.