android-testing

Provide Android testing patterns for JUnit5, MockK, Turbine, and Compose UI.

1|Updated Dec 3, 2024
One-click install
npx skills add https://github.com/Enso-Soft/lotto-assist --skill android-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-testing
Source: https://github.com/Enso-Soft/lotto-assist/tree/main/.claude/skills/android-testing
Command: npx skills add https://github.com/Enso-Soft/lotto-assist --skill android-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides Android testing patterns and templates for JUnit5, MockK, Turbine, and Compose UI testing, helping you write reliable tests faster and with consistent quality.

Core Features & Use Cases

  • Testing Stack: Unit tests with JUnit5 + MockK for ViewModel/UseCase/Repository; Turbine for Flow testing; kotlinx-coroutines-test for coroutine testing; Compose UI testing for Compose.
  • Quality Targets: Guidance on coverage goals across Domain, Presentation, and Data layers to ensure maintainable code.
  • Templates & Naming: Ready-to-use test templates and Kotlin test naming conventions to improve readability and consistency.

Quick Start

Create a sample ViewModel test for a Login screen using JUnit5, MockK, and Turbine.

Frequently Asked Questions about android-testing

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

FAQPage Schema
How do I write unit tests for Android ViewModels using JUnit5 and MockK?

Unit tests for Android ViewModels use JUnit5 as the test framework, MockK to mock dependencies, and Turbine to assert Flow emissions. This stack enables isolated testing of ViewModel logic without Android framework dependencies, improving test speed and reliability.

What's the best way to test Kotlin Flow and coroutines in Android?

Turbine is a testing library designed for Flow testing that provides a simple API to assert emitted values. Combined with kotlinx-coroutines-test, it enables reliable coroutine testing across ViewModel, UseCase, and repository layers without flaky timing issues.

Can I test Compose UI with the same testing patterns as traditional Android views?

Compose UI testing uses dedicated Compose testing APIs integrated into JUnit5 test suites. Patterns differ from traditional views but follow the same MockK and Turbine approaches for testing logic layers, providing consistency across unit, UI, and integration tests.

How do I structure tests across domain, presentation, and data layers?

Testing patterns cover all three layers: domain layer uses UseCase tests with MockK, presentation layer tests ViewModels with Turbine for Flows, and data layer tests repositories with mocked dependencies. Templates and naming conventions ensure consistency and maintainable coverage targets.

Does JUnit5 work with Hilt dependency injection in Android projects?

JUnit5 integrates with Hilt through test annotations and setup snippets provided in templates. This Skill covers Hilt integration patterns to enable dependency injection in test environments while maintaining isolation through MockK.