testing

A set of Android testing rules for unit tests, component integration tests, and user-interface tests.

In plain words
What is it for?
It guides tests for ViewModels, use cases, repositories, Compose screens, navigation flows, and critical end-to-end user journeys.
Why use it?
It helps teams test user-visible behavior with maintainable test doubles, instead of relying on fragile implementation details or excessive mocking.

Cursor rule

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 rules/rananadeemaslam/android-ai-skills/testing
Clone the repo
git clone --depth 1 https://github.com/RanaNadeemAslam/android-ai-skills
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,658 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.00000 $0.01658
Opus 5 $0.00000 $0.00829
Sonnet 5 $0.00000 $0.00332
Haiku 4.5 $0.00000 $0.00166

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

Security

Grade A, and why

testing 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.

cursor/rules/testing.mdc · 241 lines

How it starts

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

You are an expert in Android testing. Follow the testing pyramid. Use test doubles (fakes) over mocking libraries. Test behavior, not implementation details.

Testing Strategy

Source: https://developer.android.com/training/testing/fundamentals

DO:

  • Follow the testing pyramid:
    • Unit tests (70%) — fast, run on JVM, test ViewModels, UseCases, Repositories
    • Integration tests (20%) — test component interaction, navigation flows
    • UI/E2E tests (10%) — test critical user journeys end-to-end
  • Write tests from day one — not as an afterthought
  • Test behavior ("when X happens, Y should result"), not implementation details

DON'T:

  • Skip testing because "it's a small project"
  • Write tests that break when internal implementation changes but behavior stays the same
  • Aim for 100% coverage at the expense of meaningful tests — focus on critical paths

Test Doubles (Fakes over Mocks)

Source: https://developer.android.com/training/testing (Now in Android pattern)

DO:

  • Create fake implementations of interfaces for testing:
class FakeArticleRepository : ArticleRepository {
    private val articles = MutableStateFlow<List<Article>>(emptyList())

    override fun observeArticles(): Flow<List<Article>> = articles

    override suspend fun sync(): Result<Unit> {
        articles.value = listOf(
            Article(id = "1", title = "Test Article", body = "Body"),
        )
        return Result.success(Unit)
    }

    fun setArticles(list: List<Article>) {
        articles.value = list
    }
}
  • Place fakes in a shared testing module so they can be reused across test targets:
:core:testing  (shared test utilities and fakes)
  • Use constructor injection to swap real implementations with fakes in tests

DON'T:

  • Default to Mockito or MockK — use fakes first, mocks only when fakes are impractical
  • Mock data classes or value objects — construct real instances
  • Mock final classes or framework classes — create fakes or use Robolectric

Read the full file on GitHub · 241 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. 3d ago First seen · 241 lines · 0 tokens per session scan A ba3f79b77084

Subscribe to this mod's changes

testing is a cursor rule published in the GitHub repository RanaNadeemAslam/android-ai-skills (6 stars, last pushed 4mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,658 tokens. 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-31.