android-unit-test

A guide to writing and converting unit tests for Chromium Android code. It explains when to use host tests running on a computer, tests on an Android device or emulator, and broader device tests.

In plain words
What is it for?
Use it to create, move, or adapt Java unit tests across Chromium's host-based and device-based test suites.
Why use it?
It helps choose the lightest suitable test type, so tests avoid unnecessary device or emulator work while still checking the required Android behavior.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/chromium/chromium/android-unit-test
Any agent
npx skills add chromium/chromium --skill android-unit-test
Clone the repo
git clone --depth 1 https://github.com/chromium/chromium

Made for: Claude Code, Codex.

Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,465 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00036 $0.01465
Opus 5 $0.00018 $0.00732
Sonnet 5 $0.00007 $0.00293
Haiku 4.5 $0.00004 $0.00146

Measured 3d ago against content hash 10948c407d77, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

android-unit-test 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 3d 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-unit-test/SKILL.md · 128 lines

How it starts

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

Android Unit Testing Guide

This skill provides comprehensive guidance on choosing, writing, running, and migrating Android test cases across Chromium's three major Java test tiers (chrome_junit_tests, chrome_public_unit_test_apk, and chrome_public_test_apk).

1. Test Tier Hierarchy & Choosing the Right Suite

When writing or refactoring Android Java tests in Chromium, always aim for the lightest, fastest test tier that satisfies the requirements of the code being tested:

Target Suite Execution Environment Best For Key Constraints & Rules
chrome_junit_tests (junit/) Host JVM via Robolectric (BaseRobolectricTestRunner) Pure Java utility methods, data structures, MVC/MVC mediators (*MediatorUnitTest.java), presenter logic, string manipulation, and mock-based testing. Fastest execution. No actual hardware/emulator required. Cannot execute real native NDK code or live browser profiles without shadow structures or stubs.
chrome_public_unit_test_apk (unit_device_javatests) Device / Emulator (BaseJUnit4ClassRunner + @Batch(Batch.UNIT_TESTS)) Unit tests requiring actual Android device features (such as PackageManager checks, real layout inflating/rendering with BlankUiTestActivity, or localized JNI helper methods like CurrencyFormatter). Configured with is_unit_test = true: any attempts to initialize the main browser process or start ChromeTabbedActivity will explicitly fail.
chrome_public_test_apk (javatests/) Device / Emulator Instrumentation (ChromeTabbedActivityTestRule, BaseJUnit4ClassRunner) Full end-to-end multi-component browser profile initialization, web page interactions (startOnWebPage, embeddedTestServer), and complex UI flows across Activities. Heaviest and slowest tier. Should be reserved exclusively for full browser activity & integration flows.

Read the full file on GitHub · 128 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 3d ago First seen · 128 lines · 36 tokens per session scan A 10948c407d77

Subscribe to this mod's changes

android-unit-test is a skill published in the GitHub repository chromium/chromium (24,678 stars, last pushed yesterday), licensed BSD-3-Clause. It adds 36 tokens to every session and 1,465 once invoked, about $0.0002 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

testing-setup

Analyze and create a testing strategy for native Android apps - install testing libraries, set up test infrastructure, create harnesses for unit tests, UI tests, screenshot tests, and end-to-end tests.

android/skills · 43 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

test-flutter

Flutter App のテスト実行・静的解析・フォーマット・テスト記述ガイド.

K9i-0/ccpocket · 26 tokens

mobiai-android-testing

Use when writing or running tests in an Android project — unit tests, UI tests, choosing the right framework and patterns.

ArisGuimera/MobiAI-Core · 30 tokens

mobiai-ios-testing

Use when writing or running tests in an iOS project — unit tests, UI tests, snapshot tests, choosing the right framework.

ArisGuimera/MobiAI-Core · 31 tokens

flutter-async-test-unhandled-future-rejection

Fix flaky Flutter/Dart tests that fail in CI but pass locally due to unhandled Future rejections. Use when: (1) Test passes locally but fails in CI with cryptic errors, (2) Test creates Futures that will throw errors (e.g., network calls to fake URLs), (3) Even with .catchError() at the end, test still fails, (4)…

divinevideo/divine-mobile · 129 tokens