Skip to content

Commit

Permalink
Properly report disabled dynamic tests and containers to Android inst…
Browse files Browse the repository at this point in the history
…rumentation
  • Loading branch information
mannodermaus committed May 5, 2024
1 parent 8e9c698 commit 13ccb68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.mannodermaus.junit5.internal.runners
import android.annotation.SuppressLint
import android.util.Log
import de.mannodermaus.junit5.internal.LOG_TAG
import de.mannodermaus.junit5.internal.extensions.isDynamicTest
import org.junit.platform.engine.TestExecutionResult
import org.junit.platform.engine.reporting.ReportEntry
import org.junit.platform.launcher.TestExecutionListener
Expand Down Expand Up @@ -41,13 +42,15 @@ internal class AndroidJUnitPlatformRunnerListener(
}

override fun executionSkipped(testIdentifier: TestIdentifier, reason: String) {
if (testIdentifier.isTest) {
fireTestIgnored(testIdentifier, reason)
} else {
testTree.getTestsInSubtree(testIdentifier)
.forEach { identifier ->
fireTestIgnored(identifier, reason)
when {
testIdentifier.isTest -> fireTestIgnored(testIdentifier, reason)
testIdentifier.isDynamicTest -> fireTestIgnored(testIdentifier, reason)
testIdentifier.isContainer -> testTree.getChildren(testIdentifier).forEach { childIdentifier ->
// Only report leaf tests as skipped
if (childIdentifier.isTest || childIdentifier.isDynamicTest) {
fireTestIgnored(childIdentifier, reason)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ internal class AndroidJUnitPlatformTestTree(
): Description {
val name = nameExtractor(identifier)

return if (identifier.isTest) {

return if (identifier.isTest || identifier.isDynamicTest) {
Description.createTestDescription(
/* className = */ testPlan.getParent(identifier)
.map(nameExtractor)
Expand Down Expand Up @@ -190,10 +191,8 @@ internal class AndroidJUnitPlatformTestTree(
return testIdentifier.displayName
}

fun getTestsInSubtree(ancestor: TestIdentifier): Set<TestIdentifier> {
return modifiedTestPlan.getDescendants(ancestor)
.filter { it.isTest }
.toSet()
fun getChildren(testIdentifier: TestIdentifier): Set<TestIdentifier> {
return modifiedTestPlan.getDescendants(testIdentifier)
}

/**
Expand Down

0 comments on commit 13ccb68

Please sign in to comment.