picking-test-doubles

Select Android test doubles by mapping testing goals to Fake, Mock, Stub, Spy, Dummy, or Shadow.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill picking-test-doubles
Or copy as Structured Prompt for Agentโ–ผ
Please help me install this Agent Skill.
Skill: picking-test-doubles
Source: https://github.com/skydoves/android-testing-skills/tree/main/fundamentals/doubles/picking-test-doubles
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill picking-test-doubles

SYSTEM DOCUMENTATION & REQUIREMENTS

๐Ÿ’ก This Skill includes references (resource) components.

What problem does it solve?

It helps you choose the correct Android test double so your tests validate the right behavior without coupling to implementation details.

Core Features & Use Cases

  • Decision matrix for Fake vs Mock vs Stub vs Spy vs Dummy vs Shadow: Covers when to use each double and explains the preference order for Android testing.
  • State vs interaction guidance: Recommends fakes for state-bearing dependencies and mocks for verifying interactions; discourages spies unless refactoring is impractical.
  • Robolectric Shadow support: Explains how shadows fit the taxonomy when you must substitute Android framework behavior (e.g., time via ShadowSystemClock).
  • Concrete Android examples: Provides patterns for in-memory fakes (e.g., FakeUserRepository), interaction-focused mocks (e.g., verify / coVerify), and dummy placeholders.

Quick Start

Ask the AI to recommend whether you should use a fake, mock, stub, spy, dummy, or Robolectric shadow for your specific dependency based on what youโ€™re trying to verify (state or interactions) and show the corresponding example test structure.

Frequently Asked Questions about picking-test-doubles

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use a fake vs a mock for Android testing?โ–ผ

Prefer fakes for state-bearing dependencies to validate behavior without coupling to implementation details; use mocks only when you must verify specific interactions, such as confirming a method was called with expected parameters.

How do I substitute Android framework behavior in unit tests?โ–ผ

Use Robolectric shadows to substitute Android framework behavior in unit tests, such as controlling time progression via ShadowSystemClock, when you need realistic framework substitution without a physical device.

What is the best test double for verifying repository logic in Kotlin?โ–ผ

In-memory fakes are the best test double for verifying repository logic in Kotlin, as they validate state transitions and data handling without coupling your tests to internal implementation details.

Can I use spies instead of mocks to verify method interactions?โ–ผ

You can use spies to verify method interactions, but spies are discouraged unless refactoring your code to use mocks is impractical, as they tightly couple tests to implementation behavior.

How do I swap Hilt bindings with test doubles?โ–ผ

Swap Hilt bindings by mapping your testing intent to a specific test double like a fake or mock, replacing the production dependency in your Hilt testing modules to isolate components during integration tests.

What is a dummy test double used for in Kotlin testing?โ–ผ

A dummy test double is used as a placeholder in Kotlin testing when a dependency parameter is required for method signatures but is never actually invoked or verified during the specific test scenario.