CR

create-unit-test

Standardize unit testing in Kotlin/Android projects with Robolectric and the Arrange-Act-Assert pattern.

Install

mkdir -p .claude/skills/create-unit-test && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2317" && unzip -o skill.zip -d .claude/skills/create-unit-test && rm skill.zip

Installs to .claude/skills/create-unit-test

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Create and run unit tests following the project's architecture and guidelines (Robolectric, naming, location).
110 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Analyzing code for test planning
  • Setting up Robolectric for Android components
  • Implementing tests using Arrange-Act-Assert pattern
  • Executing unit tests via Gradle
  • Diagnosing test failures from XML reports

How it works

The skill guides the user through planning, file setup, and implementation of unit tests, mandating Robolectric for Android components and providing specific Gradle commands for execution.

Inputs & outputs

You give it
Class or component requiring unit testing
You get back
Unit test file and execution command

When to use create-unit-test

  • Create a unit test for a new class
  • Refactor existing test files
  • Debug failing Android tests

About this skill

Create Unit Test

This skill guides the creation of unit tests to ensuring consistency and correctness.

Workflow

  1. Analyze and Plan:

    • Goal: Understand what needs testing.
    • Action: Examine the source code.
    • Action: Identify "happy path" cases (core functionality).
    • Action: Identify "error cases" and "edge cases" based on likelihood.
    • Action: Do not suggest implementation details unless asked; focus on behavior.
  2. Setup Test File:

    • Naming: [OriginalClassName]Test.kt.
    • Location: [module]/src/test/java/[package/path]/.
    • Runner: If testing Android components, you MUST use Robolectric.
    • Mocking: Prefer creating Fakes over Mocks or patches. Use Mocks only if Fakes are too complex.
  3. Implement Tests:

    • Write clear, descriptive test methods.
    • Follow the "Arrange-Act-Assert" pattern.
    • Ensure all resources (strings, themes) are properly mocked or provided via Robolectric.
  4. Run Tests:

    • Command: ./gradlew :[module]:testDebugUnitTest
    • Example: ./gradlew :database:testDebugUnitTest
    • Tip: Before any commit, run ./gradlew testDebugUnitTest to ensure everything passes.
  5. Handle Failures:

    • Goal: Diagnose and fix issues.
    • Action: If a test fails, locate the full error report.
    • Path: [module]/build/test-results/testDebugUnitTest/TEST-[package.name.TestClassName].xml.
    • Example: app/build/test-results/testDebugUnitTest/TEST-com.anysoftkeyboard.janus.app.MainActivityTest.xml.

Guidelines

  • Consistency: Always place tests in the test source set, not androidTest (unless specifically writing instrumentation tests, which is rare for this skill).
  • Reliability: Avoid flaky tests. Ensure deterministic behavior.

When not to use it

  • For instrumentation tests
  • When deterministic behavior cannot be ensured

Prerequisites

Robolectric for Android components

Limitations

  • Requires Robolectric for Android components
  • Tests must be deterministic

How it compares

It enforces project-specific architectural guidelines and naming conventions rather than providing generic testing advice.

Compared to similar skills

create-unit-test side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
create-unit-test (this skill)27moNo flagsIntermediate
survey-sdk-audit328dReviewIntermediate
android-kotlin74moNo flagsIntermediate
android-jetpack-compose-expert44moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

survey-sdk-audit

PostHog

Audit PostHog survey SDK features and version requirements

336

android-kotlin

alinaqi

Android Kotlin development with Coroutines, Jetpack Compose, Hilt, and MockK testing

729

android-jetpack-compose-expert

sickn33

Expert guidance for building modern Android UIs with Jetpack Compose, covering state management, navigation, performance, and Material Design 3.

413

testing-android-code

bitwarden

This skill should be used when writing or reviewing tests for Android code in Bitwarden. Triggered by "BaseViewModelTest", "BitwardenComposeTest", "BaseServiceTest", "stateEventFlow", "bufferedMutableSharedFlow", "FakeDispatcherManager", "expectNoEvents", "assertCoroutineThrows", "createMockCipher", "createMockSend", "asSuccess", "Why is my Bitwarden test failing?", or testing questions about ViewModels, repositories, Compose screens, or data sources in Bitwarden.

611

kotlin-coroutines

vitorpamplona

Advanced Kotlin coroutines patterns for AmethystMultiplatform. Use when working with: (1) Structured concurrency (supervisorScope, coroutineScope), (2) Advanced Flow operators (flatMapLatest, combine, merge, shareIn, stateIn), (3) Channels and callbackFlow, (4) Dispatcher management and context switching, (5) Exception handling (CoroutineExceptionHandler, SupervisorJob), (6) Testing async code (runTest, Turbine), (7) Nostr relay connection pools and subscriptions, (8) Backpressure handling in event streams. Delegates to kotlin-expert for basic StateFlow/SharedFlow patterns. Complements nostr-expert for relay communication.

311

trail-sense-android-tests

kylecorry31

Add UI automation tests to Trail-Sense Android app using AutomationLibrary. Use when asked to create, add, write, or implement automated tests, UI tests, integration tests, or androidTests for Trail Sense tools. Covers test class structure, AutomationLibrary functions, and testing patterns.

11

Search skills

Search the agent skills registry