haidrrrry/compose-kotlin-agent-skills · Archived

android-kotlin-testing

Android testing patterns — ViewModel unit tests with Turbine, Compose UI semantics, Hilt TestInstallIn fakes, coroutine test dispatchers, and release quality gates. Use when writing tests, setting up CI, mocking repositories, or asking "how to test ViewModel", "Compose UI test", "Turbine StateFlow".

First seen Jun 17, 2026

Installation

$ npx skills add haidrrrry/compose-kotlin-agent-skills --skill android-kotlin-testing

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from haidrrrry/compose-kotlin-agent-skills.

npx skills add haidrrrry/compose-kotlin-agent-skills

Browse all from haidrrrry/compose-kotlin-agent-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 44
License LICENSE
Default branch main
Open issues 0
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,054 B
  • docs SUMMARY.md 332 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 3 installs

SKILL.md

Android Kotlin — Testing Module

Parent kit: [../../SKILL.md](../../SKILL.md) · Index: [../../AGENTS.md](../../AGENTS.md)

Read First

File When
[../../references/11-testing.md](../../references/11-testing.md) Turbine, fakes, Compose test tags
[../../references/05-hilt-di.md](../../references/05-hilt-di.md) TestInstallIn modules
[../../references/13-release-checklist.md](../../references/13-release-checklist.md) Pre-ship checklist

ViewModel Test Template

@OptIn(ExperimentalCoroutinesApi::class)
class FeatureViewModelTest {

    @get:Rule
    val mainDispatcherRule = MainDispatcherRule()

    private val fakeRepo = FakeFeatureRepository()
    private lateinit var viewModel: FeatureViewModel

    @Before
    fun setup() {
        viewModel = FeatureViewModel(fakeRepo)
    }

    @Test
    fun `refresh success clears loading`() = runTest {
        fakeRepo.syncResult = Result.success(Unit)

        viewModel.onEvent(FeatureUiEvent.Refresh)

        viewModel.state.test {
            skipItems(1)
            val loading = awaitItem()
            assertTrue(loading.isLoading)
            val done = awaitItem()
            assertFalse(done.isLoading)
            assertNull(done.error)
        }
    }
}

Fake Over Mock

class FakeFeatureRepository : FeatureRepository {
    var syncResult: Result<Unit> = Result.success(Unit)
    private val items = MutableStateFlow<List<Feature>>(emptyList())

    override fun observeItems(): Flow<List<Feature>> = items
    override suspend fun sync(): Result<Unit> = syncResult
}

Prefer fakes implementing real interfaces — tests behavior, not interaction order.

Compose UI Test

class FeatureScreenTest {
    @get:Rule
    val composeRule = createComposeRule()

    @Test
    fun showsEmptyState() {
        composeRule.setContent {
            AppTheme {
                FeatureContent(
                    state = FeatureUiState(items = emptyList()),
                    onEvent = {}
                )
            }
        }
        composeRule.onNodeWithTag("feature_empty").assertIsDisplayed()
    }
}

Test stateless FeatureContent, not ViewModel-integrated screen.

What to Test vs Skip

Always test Usually skip
ViewModel state transitions Room generated SQL
Repository mappers Hilt graph wiring (compile-time)
Error paths (Result.failure) Pixel-perfect screenshots
Critical user flows (instrumented) Third-party SDK internals

CI Gate

Repo skill validation must pass before merge:

python3 scripts/validate_skills.py --strict