diff --git a/build-plugin/src/main/kotlin/thunderbird.library.android.compose.gradle.kts b/build-plugin/src/main/kotlin/thunderbird.library.android.compose.gradle.kts index 517263563..7003812a7 100644 --- a/build-plugin/src/main/kotlin/thunderbird.library.android.compose.gradle.kts +++ b/build-plugin/src/main/kotlin/thunderbird.library.android.compose.gradle.kts @@ -6,6 +6,13 @@ android { configureSharedComposeConfig(libs) } +androidComponents { + beforeVariants(selector().withBuildType("release")) { variantBuilder -> + variantBuilder.enableUnitTest = false + variantBuilder.enableAndroidTest = false + } +} + dependencies { configureSharedComposeDependencies(libs) } diff --git a/core/ui/compose/testing/README.md b/core/ui/compose/testing/README.md new file mode 100644 index 000000000..21fc963cc --- /dev/null +++ b/core/ui/compose/testing/README.md @@ -0,0 +1,3 @@ +## Core - UI - Compose - Testing + +Uses [`:core:ui:compose:theme`](../theme/README.md) diff --git a/core/ui/compose/testing/build.gradle.kts b/core/ui/compose/testing/build.gradle.kts new file mode 100644 index 000000000..b72db6366 --- /dev/null +++ b/core/ui/compose/testing/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id(ThunderbirdPlugins.Library.androidCompose) +} + +android { + namespace = "app.k9mail.core.ui.compose.testing" +} + +dependencies { + implementation(projects.core.ui.compose.theme) + implementation(libs.androidx.compose.material) + + implementation(libs.bundles.shared.jvm.test.compose) +} diff --git a/core/ui/compose/testing/src/main/kotlin/app/k9mail/core/ui/compose/testing/ComposeTest.kt b/core/ui/compose/testing/src/main/kotlin/app/k9mail/core/ui/compose/testing/ComposeTest.kt new file mode 100644 index 000000000..855d0cc3a --- /dev/null +++ b/core/ui/compose/testing/src/main/kotlin/app/k9mail/core/ui/compose/testing/ComposeTest.kt @@ -0,0 +1,22 @@ +package app.k9mail.core.ui.compose.testing + +import androidx.annotation.StringRes +import androidx.compose.ui.test.junit4.ComposeContentTestRule +import androidx.compose.ui.test.junit4.createComposeRule +import org.junit.Rule +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment + +@RunWith(RobolectricTestRunner::class) +open class ComposeTest { + + @get:Rule + val composeTestRule = createComposeRule() + + fun getString(@StringRes resourceId: Int): String = RuntimeEnvironment.getApplication().getString(resourceId) + + fun runComposeTest(testContent: ComposeContentTestRule.() -> Unit): Unit = with(composeTestRule) { + testContent() + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 1d5274cd4..3fe58e05c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -49,6 +49,7 @@ include( ":core:ui:compose:common", ":core:ui:compose:designsystem", ":core:ui:compose:theme", + ":core:ui:compose:testing", ) include(