Android Testing

Configure Hilt, Mockito, and Compose Testing for Android instrumentation and unit tests.

67|7|Updated Jan 22, 2022
One-click install
npx skills add https://github.com/akitikkx/upnext --skill android-testing-akitikkx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Android Testing
Source: https://github.com/akitikkx/upnext/tree/main/.agent/skills/android_testing
Command: npx skills add https://github.com/akitikkx/upnext --skill android-testing-akitikkx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Android testing is essential to ensure app reliability across instrumentation tests, DI with Hilt, and correct mocking strategies; this guide helps teams set up robust, maintainable tests and prevent flaky tests.

Core Features & Use Cases

  • Instrumentation tests with AndroidJUnit4 and Compose Testing; ensure end-to-end UI and interaction tests run consistently.
  • Hilt testing configuration and best practices to avoid duplicate processing and ensure proper test DI.
  • Mockito configuration for unit and instrumentation tests to mock dependencies without relying on real implementations.
  • Test resilience patterns and CI stability techniques to gracefully skip tests when data is unavailable or environment differs.
  • Compose testing opt-ins and resilient test imports to improve reliability across Compose UI tests.

Quick Start

Begin by configuring Hilt for androidTest, then write a basic instrumented test to verify dependency injection and UI interaction.

Frequently Asked Questions about Android Testing

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

FAQPage Schema
How do I configure Hilt for Android instrumentation tests?

Configure Hilt for Android instrumentation tests by setting up test modules and applying best practices to ensure proper test dependency injection. This prevents duplicate annotation processing and guarantees consistent DI across Android modules.

How do I mock dependencies in Android unit tests using Mockito?

Mock dependencies in Android unit tests using Mockito to isolate components and prevent reliance on real implementations. This strategy builds robust, maintainable tests and avoids flaky behaviors across the test suite.

What is the best way to write reliable Compose UI tests?

Reliable Compose UI testing uses Compose Testing opt-ins and resilient imports to verify interactions consistently. Apply resilience patterns to gracefully skip tests when data is unavailable or the environment differs.

Does Robolectric work with Hilt and Mockito for local unit tests?

Robolectric works with Hilt and Mockito for local unit tests by enabling structured test layouts and consistent mocking without device dependencies. This ensures reliable unit testing across Android modules.

How do I skip flaky Android instrumentation tests in CI?

Skip flaky Android instrumentation tests in CI by implementing test resilience patterns. These patterns gracefully skip tests when data is unavailable or the environment differs, ensuring overall CI stability.