diff --git a/build-logic/src/main/kotlin/Dependencies.kt b/build-logic/src/main/kotlin/Dependencies.kt index b56eda35..fc109780 100644 --- a/build-logic/src/main/kotlin/Dependencies.kt +++ b/build-logic/src/main/kotlin/Dependencies.kt @@ -38,6 +38,7 @@ object libs { const val junitVintageEngine = "org.junit.vintage:junit-vintage-engine:${versions.junitVintage}" const val junitPlatformCommons = "org.junit.platform:junit-platform-commons:${versions.junitPlatform}" const val junitPlatformRunner = "org.junit.platform:junit-platform-runner:${versions.junitPlatform}" + const val apiguardianApi = "org.apiguardian:apiguardian-api:1.1.2" const val composeBom = "androidx.compose:compose-bom:${versions.composeBom}" const val composeUi = "androidx.compose.ui:ui" diff --git a/instrumentation/core/build.gradle.kts b/instrumentation/core/build.gradle.kts index 9bdea166..66bac19b 100644 --- a/instrumentation/core/build.gradle.kts +++ b/instrumentation/core/build.gradle.kts @@ -76,6 +76,11 @@ dependencies { runtimeOnly(libs.junitPlatformRunner) runtimeOnly(libs.junitJupiterEngine) + // This transitive dependency of JUnit 5 is required to be on the runtime classpath, + // since otherwise ART will print noisy logs to console when trying to resolve any + // of the annotations of JUnit 5 (see #291 for more info) + runtimeOnly(libs.apiguardianApi) + androidTestImplementation(libs.junitJupiterApi) androidTestImplementation(libs.junitJupiterParams) androidTestImplementation(libs.espressoCore) diff --git a/instrumentation/runner/src/main/kotlin/de/mannodermaus/junit5/internal/runners/AndroidJUnitPlatformRunnerListener.kt b/instrumentation/runner/src/main/kotlin/de/mannodermaus/junit5/internal/runners/AndroidJUnitPlatformRunnerListener.kt index 65578b3e..00ed722c 100644 --- a/instrumentation/runner/src/main/kotlin/de/mannodermaus/junit5/internal/runners/AndroidJUnitPlatformRunnerListener.kt +++ b/instrumentation/runner/src/main/kotlin/de/mannodermaus/junit5/internal/runners/AndroidJUnitPlatformRunnerListener.kt @@ -4,8 +4,10 @@ import android.annotation.SuppressLint import android.util.Log import de.mannodermaus.junit5.internal.LOG_TAG import org.junit.platform.engine.TestExecutionResult +import org.junit.platform.engine.reporting.ReportEntry import org.junit.platform.launcher.TestExecutionListener import org.junit.platform.launcher.TestIdentifier +import org.junit.platform.launcher.TestPlan import org.junit.runner.Description import org.junit.runner.notification.Failure import org.junit.runner.notification.RunNotifier @@ -19,6 +21,18 @@ internal class AndroidJUnitPlatformRunnerListener( private val notifier: RunNotifier ) : TestExecutionListener { + override fun testPlanExecutionStarted(testPlan: TestPlan) { + // No-op, but must be declared to avoid AbstractMethodError + } + + override fun testPlanExecutionFinished(testPlan: TestPlan) { + // No-op, but must be declared to avoid AbstractMethodError + } + + override fun reportingEntryPublished(testIdentifier: TestIdentifier?, entry: ReportEntry?) { + // No-op, but must be declared to avoid AbstractMethodError + } + override fun executionStarted(testIdentifier: TestIdentifier) { val description = testTree.getDescription(testIdentifier) if (testIdentifier.isTest) {