setting-up-host-vs-device-tests

Configure Jetpack Compose test environments for Robolectric host or device instrumentation.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/trancee/MeshLink-template --skill setting-up-host-vs-device-tests-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: setting-up-host-vs-device-tests
Source: https://github.com/trancee/MeshLink-template/tree/main/.agents/skills/android-testing-skills/compose/setup/setting-up-host-vs-device-tests
Command: npx skills add https://github.com/trancee/MeshLink-template --skill setting-up-host-vs-device-tests-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves the confusion between running Jetpack Compose tests on the JVM (Robolectric) versus real devices, preventing flaky tests and CI failures caused by incorrect environment assumptions.

Core Features & Use Cases

  • Environment Selection: Provides a clear decision matrix to determine if a test belongs in the host (fast, logic-heavy) or device (RenderThread, accessibility, screenshots) source set.
  • Configuration Guidance: Offers canonical class skeletons for both Robolectric and instrumentation tests to ensure proper setup.
  • Best Practices: Enforces strict rules against improper Thread.sleep usage and provides the correct alternatives for synchronization and animation testing.

Quick Start

Use the setting-up-host-vs-device-tests skill to determine whether your current Compose UI test should be placed in the androidHostTest or androidDeviceTest source set.

Frequently Asked Questions about setting-up-host-vs-device-tests

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

FAQPage Schema
How do I know if my Jetpack Compose UI test should run on the host or device?

Jetpack Compose UI tests should run on the host using Robolectric for fast, logic-heavy validation, while device-based instrumentation tests handle RenderThread synchronization, accessibility checks, and screenshot verification.

Why are my Robolectric Compose tests failing with animation or RenderThread issues?

Robolectric Compose tests fail with RenderThread issues because host-based execution lacks real device synchronization; you must use device-based instrumentation tests for deterministic animation testing and reliable screenshot verification.

How to configure source sets for Robolectric and instrumentation tests in Jetpack Compose?

Configure Jetpack Compose test source sets by placing host-based Robolectric tests in androidHostTest and device-based instrumentation tests in androidDeviceTest, using canonical class skeletons to ensure proper environment setup.

Can I use Thread.sleep for synchronization in Jetpack Compose UI testing?

You should not use Thread.sleep for synchronization in Jetpack Compose UI testing; instead, apply strict best practices and correct alternatives provided by the testing framework to ensure deterministic results.

What is the best way to perform screenshot verification in Jetpack Compose?

The best way to perform screenshot verification in Jetpack Compose is using device-based instrumentation tests, which reliably handle RenderThread synchronization and accessibility validation requirements across Android test targets.