Agent skill

Mockito Stale Mock Silent Trycatch Failure

by divinevideo in divinevideo/divine-mobile

Fix misleading Flutter/Dart test failures where expected data is empty ([]) or default values instead of the mocked response, caused by stale Mockito generated mocks or missing stubs being silently…

MPL-2.0Auto-check passedMobile

Install Mockito Stale Mock Silent Trycatch Failure

skills CLI
$ npx skills add divinevideo/divine-mobile --skill mockito-stale-mock-silent-trycatch-failure -a claude-code

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

GitHub CLI
$ gh skill install divinevideo/divine-mobile mockito-stale-mock-silent-trycatch-failure --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/mockito-stale-mock-silent-trycatch-failure .claude/skills/mockito-stale-mock-silent-trycatch-failure && 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
mockito-stale-mock-silent-trycatch-failure
GitHub stars
266
Token cost
~1.4k tokens
SKILL.md length
422 words
Files
1
Skills in repo
103
Repo updated
First seen
Licence
MPL-2.0

At a glance

Fix misleading Flutter/Dart test failures where expected data is empty ([]) or default values instead of the mocked response, caused by stale Mockito generated mocks or missing stubs being silently…

  • Works in 4 steps: Regenerate mocks → Identify new method calls in modified… → Add stubs for ALL methods in the call… → …
  • Test expects non-empty data but gets []
  • SKILL.md covers Problem, Context / Trigger Conditions, Solution and Verification, plus 3 more sections
  • Calls dart and flutter

What it does

Mockito Stale Mock Silent Trycatch Failure is an agent skill from divinevideo/divine-mobile. Fix misleading Flutter/Dart test failures where expected data is empty ([]) or default values instead of the mocked response, caused by stale Mockito generated mocks or missing stubs being silently swallowed by try/catch in provider/repository code. Use when: (1) Test expects non-empty data but gets [], (2) Mock stubs for a method are set up but the code under test returns fallback/empty results, (3) A PR added new methods to a service class and tests that previously passed now fail with misleading "expected X…

Its SKILL.md is about 1.4k 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 Failing and flaky tests, Cross-platform mobile apps and Root cause analysis. It works with Flutter and Dart. The licence is MPL-2.0.

When your agent uses it

  • Test expects non-empty data but gets []
  • Mock stubs for a method are set up but the code under test returns fallback/empty results
  • A PR added new methods to a service class and tests that previously passed now fail with misleading expected X
  • Actual: empty assertions

Example prompts

  • “expected X, actual: empty”
  • “Generated files are out of date”
  • “/mockito-stale-mock-silent-trycatch-failure”

Workflow steps

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

  1. Regenerate mocks
  2. Identify new method calls in modified code paths
  3. Add stubs for ALL methods in the call chain
  4. Handle non-nullable parameters

What it can do on your machine

Read from SKILL.md and the folder at commit c3d6f7e. 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:

    • dart
    • 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

    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

Mockito Stale Mock Silent Trycatch Failure loads about 1.4k tokens when it runs. Until then it costs about 202 tokens; SKILL.md has 422 words of instructions outside code blocks.

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

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 c3d6f7e, republished under its MPL-2.0 licence (© divinevideo). 422 words, ~1,401 tokens.

Download SKILL.mdSave it as .claude/skills/mockito-stale-mock-silent-trycatch-failure/SKILL.md (or your agent's skills folder).
name
mockito-stale-mock-silent-trycatch-failure
description
Fix misleading Flutter/Dart test failures where expected data is empty ([]) or default values instead of the mocked response, caused by stale Mockito generated mocks or missing stubs being silently swallowed by try/catch in provider/repository code. Use when: (1) Test expects non-empty data but gets [], (2) Mock stubs for a method are set up but the code under test returns fallback/empty results, (3) A PR added new methods to a service class and tests that previously passed now fail with misleading "expected X, actual: empty" assertions, (4) "Generated files are out of date" CI error alongside test failures. The root cause is MissingStubError thrown by unstubbed mock methods, caught by production try/catch blocks, causing silent fallback to empty state.
author
Claude Code
version
1.0.0
date
2026-02-17

Mockito Stale Mock + Silent Try/Catch Test Failures

Problem

When a PR adds new methods to a service class (e.g., AnalyticsApiService), and those methods are called from existing code paths that are wrapped in try/catch blocks, tests fail with misleading symptoms. The test assertion shows Expected: non-empty, Actual: [] or Expected: true, Actual: false — but the actual root cause is a MissingStubError being silently caught.

Context / Trigger Conditions

  • Symptom: Test expects data (non-empty list, specific values) but gets empty/default
  • No obvious error: No MissingStubError in test output because production code catches it
  • PR context: The PR added new methods to a @GenerateMocks-annotated service class
  • CI also shows: "Generated files are out of date" (stale .g.dart / .mocks.dart)
  • Existing tests were passing before the PR's changes
The Failure Chain
1. PR adds method `getBulkVideoViews()` to AnalyticsApiService
2. PR adds `_enrichVideosWithBulkStats()` to HomeFeedProvider.build()
3. _enrichVideosWithBulkStats calls getBulkVideoViews (new method)
4. Generated mock is stale — doesn't have getBulkVideoViews at all
5. Even if regenerated, test setUp doesn't stub getBulkVideoViews
6. Mock throws MissingStubError when unstubbed method is called
7. Provider's try/catch catches ALL exceptions (including MissingStubError)
8. Provider falls back to empty state → test sees [] instead of expected data

Solution

Step 1: Regenerate mocks
bash
dart run build_runner build --delete-conflicting-outputs

This updates all .g.dart and .mocks.dart files to include new methods.

Step 2: Identify new method calls in modified code paths

Trace the code path from the test's entry point. Look for any method calls on mocked services that were added or modified by the PR. Pay special attention to methods called after the already-stubbed method (e.g., enrichment/post-processing steps).

Step 3: Add stubs for ALL methods in the call chain
dart
// In test setUp():

// Existing stub (was already there)
when(mockService.getHomeFeed(
  pubkey: anyNamed('pubkey'),
  limit: anyNamed('limit'),
)).thenAnswer((_) async => HomeFeedResult(videos: mockVideos));

// NEW stubs needed for enrichment methods added by PR
when(mockService.getBulkVideoStats(
  argThat(isA<List<String>>()),  // non-nullable positional param
)).thenAnswer((_) async => <String, BulkVideoStatsEntry>{});

when(mockService.getBulkVideoViews(
  argThat(isA<List<String>>()),  // non-nullable positional param
  maxVideos: anyNamed('maxVideos'),
  maxConcurrent: anyNamed('maxConcurrent'),
)).thenAnswer((_) async => <String, int>{});
Step 4: Handle non-nullable parameters

Mockito's any returns null which fails for non-nullable params. Use:

  • argThat(isA<List<String>>()) for non-nullable positional params
  • anyNamed('paramName') works for named params with default values (but NOT for non-nullable named params without defaults)

Verification

After fixing:

  1. Run the specific test file: flutter test test/path/to/test.dart
  2. Confirm previously failing assertions now pass
  3. Run full test suite to check for no regressions
Show full SKILL.md (157 more words)Show less

Example

Before (failing):

Expected: non-empty
  Actual: []

  test/providers/home_feed_loading_fix_test.dart 253:9

Root cause: _enrichVideosWithBulkStats called getBulkVideoStats (unstubbed) → MissingStubError → caught by provider try/catch → empty fallback state.

Fix: Added stubs in setUp() for getBulkVideoStats and getBulkVideoViews.

After (passing): All 11 tests pass, including the 2 that were failing.

Notes

  • Always regenerate mocks when a PR modifies @GenerateMocks-annotated classes. The .mocks.dart files must match the current interface.
  • Check the full call chain, not just the primary method. A getHomeFeed stub is useless if the provider then calls enrichVideos which calls 2 more unstubbed methods.
  • This pattern is invisible in test output. The MissingStubError is caught by production error handling. You'll never see it unless you add temporary print statements inside the catch block or use @GenerateNiceMocks (which returns defaults instead of throwing, potentially masking different bugs).
  • Non-nullable params in Dart null-safety: Mockito any returns null at the type level. For non-nullable positional params, use argThat(isA<Type>()) which returns a properly typed matcher.

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/mockito-stale-mock-silent-trycatch-failure of divinevideo/divine-mobile.

Open the folder on GitHubat commit c3d6f7e

Compare with similar skills

Mockito Stale Mock Silent Trycatch Failure 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.

Mockito Stale Mock Silent Trycatch Failure compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mockito Stale Mock Silent Trycatch Failure this skilldivinevideo/divine-mobile266—~1.4kAutomated safety check: PassMPL-2.0
Green GateVeryGoodOpenSource/vgv-ai-flutter-plugin170—~4.7kAutomated safety check: NotesMIT
Analyze GitHub Flakeflutter/flutter180k—~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 5 days ago
    MobileAuto-check: notes
  • Analyze GitHub Flake

    flutter/flutter

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

    180k 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 27 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 yesterday
    Testing & QAAuto-check passed
  • MCP Debugger

    debugmcp/mcp-debugger

    A skill your agent uses when investigating a bug, failing test, or unexpected runtime behavior and the mcp-debugger MCP server is available — drives real step-through debuggers (breakpoints, stack…

    174 GitHub stars~4.2k tokensUpdated today
    DevelopmentAuto-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 Mockito Stale Mock Silent Trycatch Failure

What does Mockito Stale Mock Silent Trycatch Failure do?

Fix misleading Flutter/Dart test failures where expected data is empty ([]) or default values instead of the mocked response, caused by stale Mockito generated mocks or missing stubs being silently…. Mockito Stale Mock Silent Trycatch Failure is an agent skill from divinevideo/divine-mobile. Fix misleading Flutter/Dart test failures where expected data is empty ([]) or default values instead of the mocked response, caused by stale Mockito generated mocks or missing stubs being silently swallowed by try/catch in provider/repository code.

When should I use Mockito Stale Mock Silent Trycatch Failure?

Mockito Stale Mock Silent Trycatch Failure fits situations like: test expects non-empty data but gets []; mock stubs for a method are set up but the code under test returns fallback/empty results; A PR added new methods to a service class and tests that previously passed now fail with misleading expected X; actual: empty assertions.

How do I install Mockito Stale Mock Silent Trycatch Failure in Claude Code?

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

How do I install Mockito Stale Mock Silent Trycatch Failure in Codex?

Run `npx skills add divinevideo/divine-mobile --skill mockito-stale-mock-silent-trycatch-failure -a codex`. Or copy the skill folder (.agents/skills/mockito-stale-mock-silent-trycatch-failure in divinevideo/divine-mobile) into .agents/skills/mockito-stale-mock-silent-trycatch-failure in your project. Codex loads it when a task matches its description.

Can I use Mockito Stale Mock Silent Trycatch Failure 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 mockito-stale-mock-silent-trycatch-failure -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mockito-stale-mock-silent-trycatch-failure, .gemini/skills/mockito-stale-mock-silent-trycatch-failure, .github/skills/mockito-stale-mock-silent-trycatch-failure and .opencode/skills/mockito-stale-mock-silent-trycatch-failure in your project.

What does Mockito Stale Mock Silent Trycatch Failure need to run?

Going by SKILL.md and its folder, Mockito Stale Mock Silent Trycatch Failure needs the command-line tools its instructions call (dart and flutter).

Does Mockito Stale Mock Silent Trycatch Failure access the network?

SKILL.md names 1 domain. As links in the text: pub.dev. This is read from the text; nothing was executed.

Is Mockito Stale Mock Silent Trycatch Failure 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 Mockito Stale Mock Silent Trycatch Failure use?

Mockito Stale Mock Silent Trycatch Failure 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 Mockito Stale Mock Silent Trycatch Failure use?

About 1.4k tokens (SKILL.md is roughly 5.6k 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 Mockito Stale Mock Silent Trycatch Failure?

Skills that share tags, products or a category with Mockito Stale Mock Silent Trycatch Failure: Green Gate (VeryGoodOpenSource/vgv-ai-flutter-plugin, 170 stars), Analyze GitHub Flake (flutter/flutter, 180k 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 Mockito Stale Mock Silent Trycatch Failure?

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 10, 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.