Skip to content

Commit 9b191b7

Browse files
fix(#223): fix issue on test environment SLF4J + agent warnings in test env (#129)
- Added `slf4j-android` as a test dependency to provide a proper SLF4J binding and avoid "StaticLoggerBinder" warnings. - Configured JVM args for Gradle test tasks to enable dynamic agent loading, suppressing Byte Buddy agent warnings during test runs.
1 parent 18df293 commit 9b191b7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,14 @@ dependencies {
245245
testImplementation(libs.junit)
246246
testImplementation(libs.mockk)
247247
testImplementation(libs.turbine)
248+
testImplementation(libs.slf4j.android)
248249
testImplementation(libs.kotlinx.coroutines.tests)
249250

250251
androidTestImplementation(platform(libs.androidx.compose.bom))
251252
androidTestImplementation(libs.bundles.androidx.compose.ui.test)
252253
androidTestImplementation(libs.bundles.android.test)
253254
androidTestImplementation(libs.fastlane.screengrab)
255+
androidTestImplementation(libs.slf4j.android)
254256
}
255257

256258
val ktlintCheck by tasks.registering(JavaExec::class) {
@@ -283,4 +285,8 @@ tasks.register<JavaExec>("ktlintFormat") {
283285
"**.kts",
284286
"!**/build/**",
285287
)
286-
}
288+
}
289+
290+
tasks.withType<Test> {
291+
jvmArgs("-XX:+EnableDynamicAgentLoading")
292+
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ koin-annotation-bom = "2.1.0"
3535
ksp = "2.0.0-1.0.24"
3636
turbine = "1.2.1"
3737
coroutines = "1.10.2"
38+
slf4j = "1.7.36"
3839

3940
[libraries]
4041
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core-ktx" }
@@ -122,6 +123,7 @@ koin-annotation-compiler = { module = "io.insert-koin:koin-ksp-compiler", versio
122123
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
123124
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
124125
kotlinx-coroutines-tests = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
126+
slf4j-android = { module = "org.slf4j:slf4j-android", version.ref = "slf4j" }
125127

126128
[bundles]
127129
androidx-lifecycle = ["androidx-lifecycle-runtime", "androidx-lifecycle-viewmodel", "androidx-lifecycle-viewmodel-compose"]

0 commit comments

Comments
 (0)