File tree Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ plugins {
2+ alias(libs.plugins.kotlin)
3+ alias(libs.plugins.compose)
4+ id(" jacoco" )
5+ }
6+
7+ jacoco {
8+ toolVersion = " [0.8.13-SNAPSHOT,)"
9+ }
10+
11+ repositories {
12+ maven {
13+ url = uri(" https://oss.sonatype.org/content/repositories/snapshots" )
14+ mavenContent {
15+ snapshotsOnly()
16+ includeGroup(" org.jacoco" )
17+ }
18+ }
19+ google()
20+ mavenCentral()
21+ }
22+
23+ dependencies {
24+ implementation(compose.desktop.currentOs)
25+ testImplementation(compose.desktop.uiTestJUnit4)
26+ testImplementation(libs.junit.api)
27+ testRuntimeOnly(libs.junit.engine)
28+ }
Original file line number Diff line number Diff line change 1+ [versions ]
2+ junit5 = " 5.10.2"
3+
4+ [plugins ]
5+ compose = " org.jetbrains.compose:1.6.2"
6+ kotlin = " org.jetbrains.kotlin.jvm:1.9.23"
7+
8+ [libraries ]
9+ junit-api = { module = " org.junit.jupiter:junit-jupiter-api" , version.ref = " junit5" }
10+ junit-engine = { module = " org.junit.vintage:junit-vintage-engine" , version.ref = " junit5" }
Original file line number Diff line number Diff line change 1+ package org.example
2+
3+ import androidx.compose.material.Button
4+ import androidx.compose.material.Text
5+ import androidx.compose.runtime.*
6+
7+ @Composable
8+ fun example () {
9+ var counter by remember { mutableStateOf(0 ) }
10+ if (counter == 2 ) {
11+ return
12+ }
13+ Button (onClick = { counter++ }) {
14+ if (counter == 0 ) {
15+ Text (" Click me" )
16+ } else {
17+ Text (" Click me again" )
18+ }
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ package org.example
2+
3+ import androidx.compose.ui.test.junit4.createComposeRule
4+ import androidx.compose.ui.test.onNodeWithText
5+ import androidx.compose.ui.test.performClick
6+ import org.junit.Rule
7+ import org.junit.Test
8+
9+ class ExampleTest {
10+
11+ @get:Rule
12+ val compose = createComposeRule()
13+
14+ @Test
15+ fun test () {
16+ compose.setContent {
17+ example()
18+ }
19+ compose.onNodeWithText(" Click me" ).performClick()
20+ compose.onNodeWithText(" Click me again" ).performClick()
21+ compose.onNodeWithText(" Click me" ).assertDoesNotExist()
22+ compose.onNodeWithText(" Click me again" ).assertDoesNotExist()
23+ }
24+
25+ }
You can’t perform that action at this time.
0 commit comments