android-do-not-mock

android-do-not-mock is a skill for Claude Code, Codex from chromium/chromium. It costs 96 tokens per session (3,156 once invoked), scanned A, original, BSD-3-Clause.

A guide for writing Chromium Java tests for Android without mocking or spying on Android views or activities. It uses real framework objects or Robolectric, a test library that simulates Android on a development machine.

In plain words
What is it for?
Use it to fix DoNotMock errors, remove prohibited Mockito mocks or spies, and write Robolectric or JUnit tests for Android UI code.
Why use it?
Mocks of views and activities often return unrealistic default values and can make tests check internal calls instead of real behavior. This guidance helps replace those tests with checks of observable state.

Skill for Claude CodeCodex

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

Good fit Use it to fix DoNotMock errors, remove prohibited Mockito mocks or spies, and write Robolectric or JUnit tests for Android UI code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chromium/chromium/android-do-not-mock
About the project

Chromium is an open-source web browser project and the official GitHub mirror of its source code. It is used to build and maintain software for browsing the web, with documentation and code for products such as Chrome and Android WebView.

chromium/chromium · 25,043 stars · on GitHub · chromium.googlesource.com

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 chromium/chromium --skill android-do-not-mock
Clone the repo
git clone --depth 1 https://github.com/chromium/chromium

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 android-do-not-mock

README.md
[![agentmods](https://agentmods.dev/badge/skills/chromium/chromium/android-do-not-mock/github.svg)](https://agentmods.dev/skills/chromium/chromium/android-do-not-mock)
Your own site
<a href="https://agentmods.dev/skills/chromium/chromium/android-do-not-mock"><img src="https://agentmods.dev/badge/skills/chromium/chromium/android-do-not-mock/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.

agentmods 80×15 button for android-do-not-mock

Your own site · 80×15
<a href="https://agentmods.dev/skills/chromium/chromium/android-do-not-mock"><img src="https://agentmods.dev/badge/skills/chromium/chromium/android-do-not-mock.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 96 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,156 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.00096 $0.03156
Opus 5.5 $0.00038 $0.01262
Sonnet 5.5 $0.00019 $0.00631
Haiku 4.5 $0.00010 $0.00316

Measured 10d ago against content hash b10d32a821c5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

android-do-not-mock 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 10d 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.

agents/skills/android-do-not-mock/SKILL.md · 212 lines

How it starts

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

Writing Tests Without Mocking View / Activity

Chromium's custom Error Prone DoNotMock check rejects mocks and spies of android.view.View, android.app.Activity and their subclasses (RecyclerView, FrameLayout, ListView, ImageButton, ComponentActivity, ...). Mocked framework classes return defaults for everything (0, null, false), silently diverge from real behaviour, and make tests assert on implementation details. The check lives in tools/android/errorprone_plugin/src/org/chromium/tools/errorprone/plugin/ChromiumDoNotMockChecker.java.

Mocking other types is fine: Window, ViewTreeObserver, WindowInsetsController, RecyclerView.Adapter, LayoutManager, InputMethodManager, AppTask, MenuItem, DragEvent, delegates, etc.

Decision order (prefer earlier options)

  1. Real object, real state. new View(context), new FrameLayout(...), Robolectric.buildActivity(Activity.class).setup().get(). Assert on observable state, not on calls.
  2. Built-in Robolectric shadow. Shadows.shadowOf(x) exposes recorded state for most things you'd otherwise verify().
  3. Re-judge the assert. If the only reason for a subclass is to count or capture an internal framework call, ask whether the assert is meaningful to what the test verifies. Replace it with a behavioural check, or drop it if another assert already covers the behaviour.
  4. Fake a non-View collaborator. Subclass/spy/mock a LayoutManager, Adapter, PackageManager (via shadow), Window, ViewTreeObserver.
  5. Minimal custom subclass (last resort). Only when production calls a method whose result must be controlled and Robolectric can't set it. Keep it to a single override, private static, and comment why it's needed.

Never re-introduce @SuppressWarnings("DoNotMock") as the fix.

Getting a real Context / Activity

Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
// or: ActivityController<Activity> c = Robolectric.buildActivity(Activity.class);
//     c.create();  ... c.start().resume();  ... c.pause().stop();
Context context = ApplicationProvider.getApplicationContext();

Read the full file on GitHub · 212 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. 10d ago First seen · 212 lines · 96 tokens per session scan A b10d32a821c5

Subscribe to this mod's changes

android-do-not-mock is a skill published in the GitHub repository chromium/chromium (25,043 stars, last pushed today), licensed BSD-3-Clause. It adds 96 tokens to every session and 3,156 once invoked, about $0.0004 per session on Opus 5.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-10-06.

Related

Other skills, from other repositories

swift-protocol-di-testing

Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.

affaan-m/ECC · 32 tokens

agent-browser

Browser automation via Chrome/Chromium CDP — open, snapshot, click, screenshot. For testing web apps, mobile layouts, and automated interactions without Playwright/Puppeteer.

x-cmd/x-cmd · 39 tokens

react-native-testing

Write tests using React Native Testing Library (RNTL) v13 and v14 (@testing-library/react-native). Use when writing, reviewing, or fixing React Native component tests. Covers: render, screen, queries (getBy/getAllBy/queryBy/findBy), Jest matchers, userEvent, fireEvent, waitFor, and async patterns. Supports v13 (React…

callstack/react-native-testing-library · 134 tokens

flutter-add-widget-test

Implement a component-level test using WidgetTester to verify UI rendering and user interactions (tapping, scrolling, entering text). Use when validating that a specific widget displays correct data and responds to events as expected.

flutter/agent-plugins · 48 tokens

playwright-skill

Generates production-grade Playwright automation scripts and E2E tests in TypeScript, JavaScript, Python, Java, or C#. Supports local execution and TestMu AI cloud across 3000+ browser/OS combinations and real mobile devices. Use when the user asks to write Playwright tests, automate browsers, run cross-browser tests…

LambdaTest/agent-skills · 139 tokens

flutter-testing-skill

Generates Flutter widget tests, integration tests, and golden tests in Dart. Supports local execution and TestMu AI cloud for real device testing. Use when user mentions "Flutter", "widget test", "WidgetTester", "testWidgets", "fluttertest", "integrationtest". Triggers on: "Flutter", "widget test", "Dart test"…

LambdaTest/agent-skills · 89 tokens