Add core:ui:compose:testing module with ComposeTest and build plugin fix for non working release build type tests

This commit is contained in:
Wolf Montwé 2023-03-02 14:03:28 +01:00
parent 709b55f2d1
commit 16504bc54d
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
5 changed files with 47 additions and 0 deletions

View file

@ -6,6 +6,13 @@ android {
configureSharedComposeConfig(libs)
}
androidComponents {
beforeVariants(selector().withBuildType("release")) { variantBuilder ->
variantBuilder.enableUnitTest = false
variantBuilder.enableAndroidTest = false
}
}
dependencies {
configureSharedComposeDependencies(libs)
}

View file

@ -0,0 +1,3 @@
## Core - UI - Compose - Testing
Uses [`:core:ui:compose:theme`](../theme/README.md)

View file

@ -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)
}

View file

@ -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()
}
}

View file

@ -49,6 +49,7 @@ include(
":core:ui:compose:common",
":core:ui:compose:designsystem",
":core:ui:compose:theme",
":core:ui:compose:testing",
)
include(