mocking-with-mockito

mocking-with-mockito is a skill for Claude Code, Codex from skydoves/android-testing-skills. It costs 205 tokens per session (4,490 once invoked), scanned A, original, Apache-2.0.

Guidance for using Mockito, a library that creates stand-in objects for testing code, in Kotlin Android unit tests. It covers the standard Java library and Kotlin-friendly testing syntax.

In plain words
What is it for?
Use it to replace collaborators with test doubles, control their return values, check how they were called, and capture arguments in JVM unit tests.
Why use it?
It removes setup confusion around dependencies, Kotlin language conflicts, final classes, argument matching, and test initialization.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to replace collaborators with test doubles, control their return values…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/skydoves/android-testing-skills/mocking-with-mockito
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 skydoves/android-testing-skills --skill mocking-with-mockito
Clone the repo
git clone --depth 1 https://github.com/skydoves/android-testing-skills

Made for: Claude Code, Codex.

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 mocking-with-mockito

README.md
[![agentmods](https://agentmods.dev/badge/skills/skydoves/android-testing-skills/mocking-with-mockito.svg)](https://agentmods.dev/skills/skydoves/android-testing-skills/mocking-with-mockito)
Your own site
<a href="https://agentmods.dev/skills/skydoves/android-testing-skills/mocking-with-mockito"><img src="https://agentmods.dev/badge/skills/skydoves/android-testing-skills/mocking-with-mockito.svg" alt="Measured on agentmods" height="20"></a>
Per session 205 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,490 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.
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.00205 $0.04490
Opus 5 $0.00102 $0.02245
Sonnet 5 $0.00041 $0.00898
Haiku 4.5 $0.00020 $0.00449

Measured 7d ago against content hash 963529bd7f3f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

mocking-with-mockito 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 7d 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.

jvm-tests/mocking/mocking-with-mockito/SKILL.md · 311 lines

How it starts

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

Mocking with Mockito — The androidx-Native Mocking Stack

Mockito is the mocking framework androidx itself uses — 400+ test files import org.mockito across the AOSP checkout, while io.mockk returns zero hits. New Android code that wants to "match what Google does" picks Mockito + the mockito-kotlin Kotlin DSL. This skill documents the exact dependency matrix, the three setup styles, the Kotlin DSL surface, and the inline-mock-maker plumbing required for Kotlin final classes.

When to use this skill

  • The user is starting a new test suite in a Kotlin Android module and asks "what mocking library should I use".
  • The user reports Cannot mock/spy class … final class from Mockito 4.x and needs the mock-maker-inline configuration.
  • The user reports InvalidUseOfMatchersException from mixing raw values with any() / eq().
  • The user is wrestling with the when keyword clash in Kotlin (`when`(mock.foo())) and wants the whenever DSL.
  • The user wants argumentCaptor<T>() with firstValue / lastValue / allValues instead of ArgumentCaptor.forClass(...).
  • The user is migrating from MockitoAnnotations.initMocks(this) to openMocks(this) or the MockitoJUnit.rule() approach.
  • The user is mocking a final class on an instrumented test on API < 28.

When NOT to use this skill

  • The user wants coEvery / coVerify for suspend functions, deep singleton mocking via mockkObject, or static mocking via mockkStatic — use ../mocking-with-mockk/SKILL.md.
  • The user is choosing between fakes and mocks at the design level — use ../../../fundamentals/doubles/picking-test-doubles/SKILL.md. Per /test-doubles, fakes are preferred over mocks for behaviour-heavy collaborators.
  • The runner / Gradle matrix isn't set up yet — start with ../../runner/configuring-junit4-on-android/SKILL.md.
  • The user wants runTest-aware testing for coroutines — see ../../coroutines/testing-coroutines-with-runtest/SKILL.md.

Prerequisites

  • The base test wiring from ../../runner/configuring-junit4-on-android/SKILL.md is already in place (@RunWith(AndroidJUnit4::class), androidx.test.ext:junit:1.3.0, JUnit 4.13.2).
  • A Kotlin module on JDK 11+ (Mockito 5.x raised the JDK floor to Java 11).
  • A MainDispatcherRule is installed if any code-under-test touches Dispatchers.Main — see the runner skill.

Read the full file on GitHub · 311 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. 7d ago First seen · 311 lines · 205 tokens per session scan A 963529bd7f3f

Subscribe to this mod's changes

mocking-with-mockito is a skill published in the GitHub repository skydoves/android-testing-skills (318 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 205 tokens to every session and 4,490 once invoked, about $0.0010 per session on Opus 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

Other skills, from other repositories