Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[606] Fix: Incorrect imports in HomeScreenTest and MockUtil in Sample Compose androidTest #607

Open
wants to merge 2 commits into
base: chore/603-update-to-use-material-3-library-instead-of-old-material-library
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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"
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