compose-testing

compose-testing is a cursor rule for Cursor from RoninForge/roninforge-kotlin-compose. It costs 45 tokens per session (1,661 once invoked), scanned A, original, MIT.

A set of rules and examples for testing Android screens made with Jetpack Compose. It covers checking visible text and controls, screenshot comparisons, dependency injection, background tasks, and data-flow results.

In plain words
What is it for?
Use it to write Compose screen tests, screenshot tests, coroutine tests, and checks for data streams and button actions.
Why use it?
It helps verify what users see and how screens react to clicks, loading, and completed requests. It also encourages small fake data sources instead of tests that depend on real services.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it to write Compose screen tests, screenshot tests, coroutine tests, and checks for data streams and button actions.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/roninforge/roninforge-kotlin-compose/compose-testing
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/RoninForge/roninforge-kotlin-compose

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for compose-testing

README.md
[![agentmods](https://agentmods.dev/badge/rules/roninforge/roninforge-kotlin-compose/compose-testing/github.svg)](https://agentmods.dev/rules/roninforge/roninforge-kotlin-compose/compose-testing)
Your own site
<a href="https://agentmods.dev/rules/roninforge/roninforge-kotlin-compose/compose-testing"><img src="https://agentmods.dev/badge/rules/roninforge/roninforge-kotlin-compose/compose-testing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for compose-testing

Your own site · 80×15
<a href="https://agentmods.dev/rules/roninforge/roninforge-kotlin-compose/compose-testing"><img src="https://agentmods.dev/badge/rules/roninforge/roninforge-kotlin-compose/compose-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 45 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,661 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00045 $0.01661
Opus 5.5 $0.00018 $0.00664
Sonnet 5.5 $0.00009 $0.00332
Haiku 4.5 $0.00005 $0.00166

Measured 1mo ago against content hash cc402d814d69, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

compose-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/compose-testing.mdc · 204 lines

How it starts

The opening of the file, as written. The whole thing — 204 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Compose / Kotlin Android Testing

Compose UI tests

class ProfileScreenTest {

    @get:Rule
    val rule = createComposeRule()

    @Test
    fun showsLoading() {
        rule.setContent {
            AppTheme { ProfileScreen(ProfileUiState.Loading, onIntent = {}) }
        }
        rule.onNodeWithContentDescription("Loading").assertIsDisplayed()
    }

    @Test
    fun showsUserName_onSuccess() {
        val user = User("alice", "Alice", "[email protected]")
        rule.setContent {
            AppTheme { ProfileScreen(ProfileUiState.Success(user), onIntent = {}) }
        }
        rule.onNodeWithText("Alice").assertIsDisplayed()
        rule.onNodeWithText("[email protected]").assertIsDisplayed()
    }

    @Test
    fun invokesOnIntent_whenButtonClicked() {
        val user = User("alice", "Alice", "[email protected]")
        var intent: ProfileIntent? = null
        rule.setContent {
            AppTheme {
                ProfileScreen(ProfileUiState.Success(user), onIntent = { intent = it })
            }
        }
        rule.onNodeWithText("Refresh").performClick()
        assertEquals(ProfileIntent.Refresh, intent)
    }
}

Test the stateless Screen composable. It takes state and lambdas, so the test never needs a ViewModel.

Semantic matchers

Prefer semantic queries over node-tree introspection:

  • onNodeWithText("Alice") - visible text content.
  • onNodeWithContentDescription("Profile avatar") - for icons/images.
  • onNodeWithTag("submit-button") - via Modifier.testTag(...) (use sparingly; tags are not visible to users).
  • onAllNodesWithText(...) - when multiple nodes match.

Custom matchers:

rule.onNode(hasText("Save") and hasClickAction()).performClick()

ViewModel tests with runTest + Turbine

class ProfileViewModelTest {

    @get:Rule
    val mainDispatcherRule = MainDispatcherRule()  // sets Dispatchers.Main to a test dispatcher

    @Test
    fun emitsSuccess_whenRepoReturnsUser() = runTest {
        val user = User("alice", "Alice", "[email protected]")
        val repo = FakeProfileRepository(user = user)
        // Build the route's SavedStateHandle via navigation-testing so toRoute<Profile>() works.
        val savedState = Profile("alice").let {
            SavedStateHandle().apply { set("userId", "alice") }  // see note below
        }
        val vm = ProfileViewModel(repo, savedState)

        vm.state.test {
            assertEquals(ProfileUiState.Loading, awaitItem())
            val item = awaitItem()
            assertTrue(item is ProfileUiState.Success)
            assertEquals("Alice", (item as ProfileUiState.Success).user.name)
            cancelAndIgnoreRemainingEvents()
        }
    }
}

Read the full file on GitHub · 204 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 204 lines · 45 tokens per session scan A cc402d814d69

Subscribe to this mod's changes

compose-testing is a cursor rule published in the GitHub repository RoninForge/roninforge-kotlin-compose (1 stars, last pushed 4mo ago), licensed MIT. It adds 45 tokens to every session and 1,661 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.