picking-test-doubles

Determine optimal Android test doubles using Google's preference hierarchy.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/trancee/MeshLink-template --skill picking-test-doubles-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: picking-test-doubles
Source: https://github.com/trancee/MeshLink-template/tree/main/.agents/skills/android-testing-skills/fundamentals/doubles/picking-test-doubles
Command: npx skills add https://github.com/trancee/MeshLink-template --skill picking-test-doubles-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves the common issue of over-mocking in Android testing, which leads to brittle tests that focus on implementation details rather than actual behavior.

Core Features & Use Cases

  • Decision Matrix: Provides a clear framework for choosing between fakes, mocks, stubs, spies, dummies, and shadows based on your specific testing intent.
  • Best Practices: Enforces Google's preferred testing hierarchy, prioritizing fakes over mocks to ensure tests are lightweight and maintainable.
  • Use Case: When you are unsure whether to use a Mockito mock or a custom FakeRepository for a ViewModel test, this skill guides you to the correct choice to avoid unnecessary complexity.

Quick Start

Use the picking-test-doubles skill to determine whether a fake or a mock is appropriate for the current test scenario.

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 in Android unit tests?

Choose fake vs mock based on dependency state and interaction needs. Fakes are ideal for state-bearing dependencies to keep tests maintainable, while mocks verify specific interactions without coupling to implementation details.

How do I stop Mockito from making my Android tests brittle?

To stop Mockito from making Android tests brittle, shift to fakes for state-bearing dependencies. Fakes avoid tight coupling to implementation details, ensuring tests remain reliable and maintainable across refactors.

What is the best way to structure Android test doubles for ViewModel tests?

The best way to structure Android test doubles for ViewModel tests is using custom fakes for repositories. This approach enforces a lightweight, maintainable hierarchy by validating test design against established Google preferences.

Can I use Robolectric shadows instead of mocks for Android integration tests?

Robolectric shadows can be used for framework-level substitutions in Android integration tests. They provide specialized environment handling where fakes or mocks are insufficient for validating actual device behavior.

Why does over-mocking lead to brittle Android unit tests?

Over-mocking leads to brittle Android unit tests because it forces tests to focus on implementation details rather than actual behavior. This tight coupling causes tests to break unnecessarily during code refactoring.

Do I need dependency injection to use test doubles in Android testing?

Dependency injection is required to effectively use test doubles in Android testing. Injecting dependencies allows you to seamlessly substitute real components with fakes or mocks during unit and integration testing scenarios.