From 67a35b29ca2333498fce863260c9219b7cf6df76 Mon Sep 17 00:00:00 2001 From: MR3Y Date: Sun, 12 Nov 2023 22:21:41 +0200 Subject: [PATCH] Move robolectric tests to Shared module --- androidApp/build.gradle.kts | 10 --------- androidApp/src/main/AndroidManifest.xml | 5 ----- .../src/test/resources/robolectric.properties | 2 -- gradle/libs.versions.toml | 1 + shared/build.gradle.kts | 22 +++++++++++++++++-- shared/src/androidMain/AndroidManifest.xml | 5 +++++ .../shared}/ui/screens/BaseRobolectricTest.kt | 2 +- .../com/mr3y/ludi/shared}/ui/screens/Utils.kt | 2 +- .../ui/screens/deals/DealsScreenTest.kt | 5 ++--- .../ui/screens/deals/FakeDealsState.kt | 2 +- .../screens/onboarding/FakeOnboardingState.kt | 2 +- .../onboarding/OnboardingScreenFABTest.kt | 7 +++--- .../shared}/ui/screens/onboarding/Utils.kt | 4 ++-- .../OnboardingScreenAccessibilityTest.kt | 16 +++++++------- 14 files changed, 45 insertions(+), 40 deletions(-) delete mode 100644 androidApp/src/test/resources/robolectric.properties rename {androidApp/src/test/kotlin/com/mr3y/ludi => shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared}/ui/screens/BaseRobolectricTest.kt (90%) rename {androidApp/src/test/kotlin/com/mr3y/ludi => shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared}/ui/screens/Utils.kt (95%) rename {androidApp/src/test/kotlin/com/mr3y/ludi => shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared}/ui/screens/deals/DealsScreenTest.kt (96%) rename {androidApp/src/test/kotlin/com/mr3y/ludi => shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared}/ui/screens/deals/FakeDealsState.kt (99%) rename {androidApp/src/test/kotlin/com/mr3y/ludi => shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared}/ui/screens/onboarding/FakeOnboardingState.kt (99%) rename {androidApp/src/test/kotlin/com/mr3y/ludi => shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared}/ui/screens/onboarding/OnboardingScreenFABTest.kt (96%) rename {androidApp/src/test/kotlin/com/mr3y/ludi => shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared}/ui/screens/onboarding/Utils.kt (80%) rename {androidApp/src/test/kotlin/com/mr3y/ludi => shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared}/ui/screens/onboarding/accessibility/OnboardingScreenAccessibilityTest.kt (94%) diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 04b76f27..4eaa7136 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -102,7 +102,6 @@ dependencies { implementation(libs.views.material) implementation(libs.androidx.lifecycle.runtime.ktx) implementation(libs.androidx.lifecycle.runtime.compose) - implementation(libs.androidx.activity.compose) implementation(libs.splash.screen) implementation(project(":shared")) @@ -120,16 +119,7 @@ dependencies { implementation(compose.runtime) implementation(compose.foundation) implementation(libs.accompanist.system.ui.controller) - implementation(libs.voyager.navigator) // Tooling debugImplementation(compose.uiTooling) - debugImplementation(libs.androidx.compose.ui.test.manifest) - - // Local tests: jUnit, coroutines, Android runner - testImplementation(libs.junit) - testImplementation(libs.robolectric) - testImplementation(libs.androidx.test.core) - testImplementation(libs.paging.testing) - testImplementation(libs.androidx.compose.ui.test.junit4) } diff --git a/androidApp/src/main/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml index d72214fa..370e39a0 100644 --- a/androidApp/src/main/AndroidManifest.xml +++ b/androidApp/src/main/AndroidManifest.xml @@ -19,11 +19,6 @@ android:theme="@style/Theme.Ludi.Splash" android:name=".LudiApplication" tools:targetApi="31"> - - + + + + \ No newline at end of file diff --git a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/BaseRobolectricTest.kt b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/BaseRobolectricTest.kt similarity index 90% rename from androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/BaseRobolectricTest.kt rename to shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/BaseRobolectricTest.kt index 9a5a9bd4..37c274a6 100644 --- a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/BaseRobolectricTest.kt +++ b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/BaseRobolectricTest.kt @@ -1,4 +1,4 @@ -package com.mr3y.ludi.ui.screens +package com.mr3y.ludi.shared.ui.screens import androidx.compose.ui.test.junit4.createComposeRule import org.junit.Before diff --git a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/Utils.kt b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/Utils.kt similarity index 95% rename from androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/Utils.kt rename to shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/Utils.kt index 294527e6..1c79309b 100644 --- a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/Utils.kt +++ b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/Utils.kt @@ -1,4 +1,4 @@ -package com.mr3y.ludi.ui.screens +package com.mr3y.ludi.shared.ui.screens import android.content.Context import androidx.compose.ui.semantics.Role diff --git a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/deals/DealsScreenTest.kt b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/deals/DealsScreenTest.kt similarity index 96% rename from androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/deals/DealsScreenTest.kt rename to shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/deals/DealsScreenTest.kt index 1d3c7a90..61c1e3ac 100644 --- a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/deals/DealsScreenTest.kt +++ b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/deals/DealsScreenTest.kt @@ -1,4 +1,4 @@ -package com.mr3y.ludi.ui.screens.deals +package com.mr3y.ludi.shared.ui.screens.deals import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass @@ -19,8 +19,7 @@ import androidx.compose.ui.test.performClick import cafe.adriel.lyricist.LocalStrings import com.mr3y.ludi.shared.ui.adaptive.LocalWindowSizeClass import com.mr3y.ludi.shared.ui.resources.LudiStrings -import com.mr3y.ludi.shared.ui.screens.deals.DealsScreen -import com.mr3y.ludi.ui.screens.BaseRobolectricTest +import com.mr3y.ludi.shared.ui.screens.BaseRobolectricTest import com.mr3y.ludi.shared.ui.theme.LudiTheme import org.junit.Test import org.junit.runner.RunWith diff --git a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/deals/FakeDealsState.kt b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/deals/FakeDealsState.kt similarity index 99% rename from androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/deals/FakeDealsState.kt rename to shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/deals/FakeDealsState.kt index 1d91f5bc..adb15dca 100644 --- a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/deals/FakeDealsState.kt +++ b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/deals/FakeDealsState.kt @@ -1,4 +1,4 @@ -package com.mr3y.ludi.ui.screens.deals +package com.mr3y.ludi.shared.ui.screens.deals import androidx.paging.LoadStates import app.cash.paging.LoadStateLoading diff --git a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/FakeOnboardingState.kt b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/FakeOnboardingState.kt similarity index 99% rename from androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/FakeOnboardingState.kt rename to shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/FakeOnboardingState.kt index 628fdb8f..0e8b9b02 100644 --- a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/FakeOnboardingState.kt +++ b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/FakeOnboardingState.kt @@ -1,4 +1,4 @@ -package com.mr3y.ludi.ui.screens.onboarding +package com.mr3y.ludi.shared.ui.screens.onboarding import androidx.paging.LoadStates import app.cash.paging.LoadStateLoading diff --git a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/OnboardingScreenFABTest.kt b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/OnboardingScreenFABTest.kt similarity index 96% rename from androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/OnboardingScreenFABTest.kt rename to shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/OnboardingScreenFABTest.kt index 77f56070..5fe71278 100644 --- a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/OnboardingScreenFABTest.kt +++ b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/OnboardingScreenFABTest.kt @@ -1,4 +1,4 @@ -package com.mr3y.ludi.ui.screens.onboarding +package com.mr3y.ludi.shared.ui.screens.onboarding import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -12,10 +12,9 @@ import com.mr3y.ludi.shared.core.model.GameGenre import com.mr3y.ludi.shared.ui.presenter.model.FavouriteGame import com.mr3y.ludi.shared.ui.presenter.model.NewsDataSource import com.mr3y.ludi.shared.ui.resources.LudiStrings -import com.mr3y.ludi.ui.screens.BaseRobolectricTest -import com.mr3y.ludi.ui.screens.onNodeWithStateDescription +import com.mr3y.ludi.shared.ui.screens.BaseRobolectricTest +import com.mr3y.ludi.shared.ui.screens.onNodeWithStateDescription import com.mr3y.ludi.shared.ui.theme.LudiTheme -import com.mr3y.ludi.shared.ui.screens.onboarding.OnboardingScreen import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner diff --git a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/Utils.kt b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/Utils.kt similarity index 80% rename from androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/Utils.kt rename to shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/Utils.kt index 35ef11e6..13e58fba 100644 --- a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/Utils.kt +++ b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/Utils.kt @@ -1,10 +1,10 @@ -package com.mr3y.ludi.ui.screens.onboarding +package com.mr3y.ludi.shared.ui.screens.onboarding import androidx.compose.ui.semantics.Role import androidx.compose.ui.test.SemanticsNodeInteraction import androidx.compose.ui.test.hasStateDescription import androidx.compose.ui.test.junit4.ComposeContentTestRule -import com.mr3y.ludi.ui.screens.hasRole +import com.mr3y.ludi.shared.ui.screens.hasRole internal fun ComposeContentTestRule.onGenre(genreStateDesc: String): SemanticsNodeInteraction { return onNode(hasStateDescription(genreStateDesc) and hasRole(Role.Checkbox)) diff --git a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/accessibility/OnboardingScreenAccessibilityTest.kt b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/accessibility/OnboardingScreenAccessibilityTest.kt similarity index 94% rename from androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/accessibility/OnboardingScreenAccessibilityTest.kt rename to shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/accessibility/OnboardingScreenAccessibilityTest.kt index 872e9beb..feb6a1a0 100644 --- a/androidApp/src/test/kotlin/com/mr3y/ludi/ui/screens/onboarding/accessibility/OnboardingScreenAccessibilityTest.kt +++ b/shared/src/androidUnitTest/kotlin/com/mr3y/ludi/shared/ui/screens/onboarding/accessibility/OnboardingScreenAccessibilityTest.kt @@ -1,4 +1,4 @@ -package com.mr3y.ludi.ui.screens.onboarding.accessibility +package com.mr3y.ludi.shared.ui.screens.onboarding.accessibility import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -20,14 +20,14 @@ import com.mr3y.ludi.shared.core.model.GameGenre import com.mr3y.ludi.shared.ui.presenter.model.FavouriteGame import com.mr3y.ludi.shared.ui.presenter.model.NewsDataSource import com.mr3y.ludi.shared.ui.resources.LudiStrings -import com.mr3y.ludi.ui.screens.BaseRobolectricTest -import com.mr3y.ludi.ui.screens.onNodeWithStateDescription -import com.mr3y.ludi.ui.screens.onboarding.FakeAllGenres -import com.mr3y.ludi.ui.screens.onboarding.FakeNewsDataSources -import com.mr3y.ludi.ui.screens.onboarding.FakeOnboardingGames -import com.mr3y.ludi.ui.screens.onboarding.FakeOnboardingState +import com.mr3y.ludi.shared.ui.screens.BaseRobolectricTest +import com.mr3y.ludi.shared.ui.screens.onNodeWithStateDescription +import com.mr3y.ludi.shared.ui.screens.onboarding.FakeAllGenres +import com.mr3y.ludi.shared.ui.screens.onboarding.FakeNewsDataSources +import com.mr3y.ludi.shared.ui.screens.onboarding.FakeOnboardingGames +import com.mr3y.ludi.shared.ui.screens.onboarding.FakeOnboardingState import com.mr3y.ludi.shared.ui.screens.onboarding.OnboardingScreen -import com.mr3y.ludi.ui.screens.onboarding.onGenre +import com.mr3y.ludi.shared.ui.screens.onboarding.onGenre import com.mr3y.ludi.shared.ui.theme.LudiTheme import kotlinx.coroutines.test.runTest import org.junit.Test