Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add apiguardian-api runtime dependency to satisfy ART's internal runtime annotation loader #306

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build-logic/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions instrumentation/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down