@@ -13,7 +13,7 @@ import org.junit.platform.launcher.TestPlan
13
13
import org.junit.platform.suite.api.SuiteDisplayName
14
14
import org.junit.platform.suite.api.UseTechnicalNames
15
15
import org.junit.runner.Description
16
- import java.util.*
16
+ import java.util.Optional
17
17
import java.util.function.Predicate
18
18
19
19
/* *
@@ -52,7 +52,6 @@ internal class AndroidJUnitPlatformTestTree(
52
52
nameComponents.add(formatTestName(currentNode))
53
53
currentNode = modifiedTestPlan.getRealParent(currentNode).orElse(null )
54
54
}
55
-
56
55
nameComponents.reverse()
57
56
58
57
// Android's Unified Test Platform (AGP 7.0+) is using literal test names
@@ -66,12 +65,15 @@ internal class AndroidJUnitPlatformTestTree(
66
65
}
67
66
68
67
private fun formatTestName (identifier : TestIdentifier ): String {
69
- // During isolated executions, construct a technical version of the test name
70
- // for backwards compatibility with the JUnit 4-based instrumentation of Android,
71
- // stripping the brackets and parameters completely.
72
- // If we didn't, then running them from the IDE doesn't work for @Test methods with parameters
73
- // (See AndroidX's TestRequestBuilder$MethodFilter for where this is cross-referenced).
74
- if (isIsolatedMethodRun) {
68
+ // During isolated executions of non-dynamic @Test methods,
69
+ // construct a technical version of the test name for backwards compatibility
70
+ // with the JUnit 4-based instrumentation of Android by stripping the brackets and parameters completely.
71
+ // If this didn't happen, running them from the IDE will cause "No tests found" errors.
72
+ // See AndroidX's TestRequestBuilder$MethodFilter for where this is cross-referenced in the instrumentation!
73
+ //
74
+ // Ref issues #199 & #207 (the original unearthing of this behavior),
75
+ // as well as #317 (making an exception for dynamic tests).
76
+ if (isIsolatedMethodRun && ! identifier.isDynamicTest) {
75
77
val reportName = identifier.legacyReportingName
76
78
val bracketIndex = reportName.indexOf(' (' )
77
79
if (bracketIndex > - 1 ) {
0 commit comments