android-unit-test

Generate JUnit, Mockito, MockK, and Espresso tests for Android applications.

19|5|Updated Nov 23, 2025
One-click install
npx skills add https://github.com/Nir-Bhay/markups --skill android-unit-test
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-unit-test
Source: https://github.com/Nir-Bhay/markups/tree/main/.agents/skills/android-unit-test
Command: npx skills add https://github.com/Nir-Bhay/markups --skill android-unit-test

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides expert guidance and code examples for writing robust unit and instrumentation tests for Android applications, ensuring code quality and stability.

Core Features & Use Cases

  • Unit Testing: Comprehensive examples for testing business logic, ViewModels, and Repositories using JUnit, Mockito, and MockK.
  • Instrumentation Testing: Demonstrations of UI testing with Espresso for verifying user interactions and UI states.
  • Coroutines & Flow Testing: Utilities and patterns for testing asynchronous code with Kotlin Coroutines and Turbine.
  • Use Case: You need to write a unit test for a ViewModel that fetches user data from a repository. This Skill provides the exact code structure, dependency setup, and assertion patterns to achieve this efficiently.

Quick Start

Use the android-unit-test skill to generate a basic JUnit test for an Android ViewModel.

Frequently Asked Questions about android-unit-test

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

FAQPage Schema
How do I write a unit test for an Android ViewModel that fetches repository data?

Android ViewModel unit testing involves structuring JUnit tests, mocking repository dependencies with MockK or Mockito, and asserting expected states. This ensures business logic stability and verifies data fetching behavior without requiring real data sources.

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

Testing Kotlin Coroutines and Flow in Android is best handled using Turbine utilities. This pattern allows you to collect and assert emissions from asynchronous streams, verifying that your repository and ViewModel Flow logic produces the correct sequential data.

How do I verify UI interactions and states with Espresso instrumentation testing?

Espresso instrumentation testing verifies UI interactions by launching your Android activity and simulating user actions like clicks and text input. This process asserts that the application's UI states update correctly in response to user behavior.

Can I use Mockito and MockK interchangeably for Android unit testing?

You can use Mockito and MockK for Android unit testing, though MockK is specifically designed for Kotlin and handles Kotlin-specific features better. Both frameworks provide patterns for mocking dependencies to isolate and test ViewModels and repositories effectively.

How do I run parameterized tests for Android business logic?

Parameterized tests for Android business logic run by feeding multiple input datasets into a single JUnit test structure. This allows you to verify various edge cases and logic branches comprehensively without duplicating test code for each scenario.