Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions sample-compose/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ android {
buildConfig = true
}

packagingOptions {
packaging {
jniLibs {
// Resolve "libmockkjvmtiagent.so" https://github.com/mockk/mockk/issues/297#issuecomment-901924678
useLegacyPackaging = true
}
resources {
merges += listOf("/META-INF/LICENSE.md", "/META-INF/LICENSE-notice.md")
}
}

lint {
Expand Down Expand Up @@ -143,15 +146,21 @@ dependencies {

// UI test with Robolectric
testImplementation(platform(libs.compose.bom))
testImplementation(libs.test.compose.ui)
testImplementation(libs.test.compose.ui.junit4)
testImplementation(libs.test.rules)
testImplementation(libs.test.robolectric)

// UI test
androidTestImplementation(platform(libs.compose.bom))
androidTestImplementation(libs.test.compose.ui)
androidTestImplementation(libs.test.compose.ui.junit4)
androidTestImplementation(libs.test.rules)
androidTestImplementation(libs.test.mockk)
androidTestImplementation(libs.test.mockk.android)

// Unable to resolve activity for Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
// cmp=co.nimblehq.sample.compose/androidx.activity.ComponentActivity } --
// see https://github.com/robolectric/robolectric/pull/4736 for details
// Ref: https://developer.android.com/develop/ui/compose/testing#setup
debugImplementation(libs.test.compose.ui.manifest)
}

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package co.nimblehq.sample.compose.test

import co.nimblehq.sample.compose.domain.model.Model
import co.nimblehq.sample.compose.domain.models.Model

object MockUtil {

Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests fail to run on my end, not sure if it's an existing issue though πŸ€”

Copy link
Contributor Author

@kaungkhantsoe kaungkhantsoe Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryan-conway It passed on my side. Not sure if anyone failed to run πŸ™

Screen.Recording.mp4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the test passed on my side

image

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it this error?

Execution failed for task ':domain:compileKotlin'.
> Inconsistent JVM-target compatibility detected for tasks 'compileJava' (17) and 'compileKotlin' (21).

I need to set target for kotlin in domain module for the test to run, else it defaults to JVM 21 causing mismatch
Screenshot 2569-01-14 at 10 14 33
Screenshot 2569-01-14 at 10 15 02

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.rule.GrantPermissionRule
import co.nimblehq.sample.compose.domain.usecase.GetModelsUseCase
import co.nimblehq.sample.compose.domain.usecase.IsFirstTimeLaunchPreferencesUseCase
import co.nimblehq.sample.compose.domain.usecase.UpdateFirstTimeLaunchPreferencesUseCase
import co.nimblehq.sample.compose.domain.usecases.GetModelsUseCase
import co.nimblehq.sample.compose.domain.usecases.IsFirstTimeLaunchPreferencesUseCase
import co.nimblehq.sample.compose.domain.usecases.UpdateFirstTimeLaunchPreferencesUseCase
import co.nimblehq.sample.compose.test.MockUtil
import co.nimblehq.sample.compose.test.TestDispatchersProvider
import co.nimblehq.sample.compose.ui.base.BaseDestination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import io.kotest.matchers.shouldBe
import io.mockk.*
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.*
import org.junit.*
import org.junit.Assert.assertEquals
import org.junit.runner.RunWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import co.nimblehq.sample.compose.domain.repositories.AppPreferencesRepository
import io.kotest.matchers.shouldBe
import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.test.runTest
import org.junit.Assert.*

import org.junit.Before
import org.junit.Test

@OptIn(ExperimentalCoroutinesApi::class)
class IsFirstTimeLaunchPreferencesUseCaseTest {

private lateinit var mockAppPreferencesRepository: AppPreferencesRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ package co.nimblehq.sample.compose.domain.usecases

import co.nimblehq.sample.compose.domain.repositories.AppPreferencesRepository
import io.mockk.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.test.runTest
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test

@OptIn(ExperimentalCoroutinesApi::class)
class UpdateFirstTimeLaunchPreferencesUseCaseTest {

private lateinit var mockAppPreferencesRepository: AppPreferencesRepository
Expand Down
14 changes: 10 additions & 4 deletions sample-compose/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ kotlinxCoroutines = "1.7.3"
kover = "0.7.3"
ksp = "2.1.0-1.0.29"
lifecycle = "2.8.7"
mockk = "1.13.5"
mockk = "1.13.8"
moshi = "1.15.1"
nimbleCommon = "0.1.2"
okhttp = "4.12.0"
retrofit = "2.11.0"
robolectric = "4.13"
security = "1.0.0"
testCore = "1.6.1"
testRules = "1.6.1"
testRules = "1.7.0-alpha01"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

🧩 Analysis chain

🌐 Web query:

androidx.test:rules 1.7.0 stable release date

πŸ’‘ Result:

androidx.test:rules 1.7.0 (stable) was released July 30, 2025. [1][2]

Sources:
[1] Android Developers β€” Test release notes (Rules 1.7.0).
[2] Android Developers β€” Recent release notes / All-channel listing.


Update testRules from alpha to stable version.

A stable version of androidx.test:rules 1.7.0 is available (released July 2025). Replace testRules = "1.7.0-alpha01" with testRules = "1.7.0" to use the stable release instead of the alpha version.

πŸ€– Prompt for AI Agents
In `@sample-compose/gradle/libs.versions.toml` at line 35, Update the testRules
version entry in libs.versions.toml: replace the current testRules =
"1.7.0-alpha01" value with the stable release testRules = "1.7.0" so the project
uses androidx.test:rules 1.7.0 instead of the alpha build.

timber = "5.0.1"
turbine = "0.13.0"

Expand Down Expand Up @@ -87,12 +87,18 @@ test-core-ktx = { group = "androidx.test", name = "core-ktx", version.ref = "tes
test-junit = { group = "junit", name = "junit", version.ref = "junit" }
test-kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }
test-kotest-assertions-core = { group = "io.kotest", name = "kotest-assertions-core", version.ref = "kotest" }
# For Unit Test
test-mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
test-turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" }
test-compose-ui = { group = "androidx.compose.ui", name = "ui-test-junit4" }
test-compose-ui-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
test-robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" }
test-rules = { group = "androidx.test", name = "rules", version.ref = "testRules" }

# For UI Test
# Ref: https://github.com/mockk/mockk/issues/325#issuecomment-549027350
test-mockk-android = { group = "io.mockk", name = "mockk-android", version.ref = "mockk" }
test-compose-ui-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }

[bundles]
androidx = [
"androidx-core",
Expand Down Expand Up @@ -129,7 +135,7 @@ unitTest = [
"test-mockk",
]
uiTest = [
"test-compose-ui",
"test-compose-ui-junit4",
"test-robolectric",
]

Expand Down