Skip to content

Commit

Permalink
Merge pull request #203 from MahdiAbbasian/kmp
Browse files Browse the repository at this point in the history
add ui test
  • Loading branch information
Kaaveh committed Mar 22, 2024
2 parents f3c3b25 + f6adda6 commit 4652707
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ dependencies {
implementation(lifecycle.runtime.ktx)
implementation(work.runtime.ktx)
implementation(libs.hilt.navigation.compose)
implementation(libs.espresso.core)
implementation(libs.compose.ui.test.manifest)
implementation(libs.compose.ui.test.junit4)
}
}
26 changes: 26 additions & 0 deletions app/src/androidTest/java/ir/composenews/ui/MainActivityTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import ir.composenews.ui.MainActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class MainActivityTest {

@get:Rule
val composeTestRule = createAndroidComposeRule<MainActivity>()

@Test
fun checkNavigationItemsDisplayed() {
composeTestRule.waitForIdle()

composeTestRule
.onNodeWithContentDescription("Favorite")
.assertIsDisplayed()
.performClick()
}
}
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ windowsSizeClass = "1.1.2"
adaptive = "0.26.2-beta"

kotest = "5.7.2"
espressoCore = "3.4.0"

[libraries]
androidx-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "ktx" }
Expand All @@ -69,6 +70,7 @@ compose-ui = { group = "androidx.compose.ui", name = "ui" }
compose-ui-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }
compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "composeMaterial3" }
compose-activity = { group = "androidx.activity", name = "activity-compose", version.ref = "composeActivity" }
Expand Down Expand Up @@ -128,6 +130,7 @@ compose-lottie-animation = { group = "com.airbnb.android", name = "lottie-compos
kotest-assertionsCore = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" }
kotest-runnerJUnit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
Expand Down

0 comments on commit 4652707

Please sign in to comment.