@@ -13,7 +13,7 @@ import org.junit.platform.launcher.TestPlan
1313import org.junit.platform.suite.api.SuiteDisplayName
1414import org.junit.platform.suite.api.UseTechnicalNames
1515import org.junit.runner.Description
16- import java.util.*
16+ import java.util.Optional
1717import java.util.function.Predicate
1818
1919/* *
@@ -52,7 +52,6 @@ internal class AndroidJUnitPlatformTestTree(
5252 nameComponents.add(formatTestName(currentNode))
5353 currentNode = modifiedTestPlan.getRealParent(currentNode).orElse(null )
5454 }
55-
5655 nameComponents.reverse()
5756
5857 // Android's Unified Test Platform (AGP 7.0+) is using literal test names
@@ -66,12 +65,15 @@ internal class AndroidJUnitPlatformTestTree(
6665 }
6766
6867 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) {
7577 val reportName = identifier.legacyReportingName
7678 val bracketIndex = reportName.indexOf(' (' )
7779 if (bracketIndex > - 1 ) {
0 commit comments