From 4e60a2dbe1e8c075973a42d946e654471dbccec3 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 13 Dec 2021 15:20:15 +0300 Subject: [PATCH] Remove unused JUnitMode.Mix mode It's not used by now, and there's are known problems with it check KTI-712. If transition to JUnit5 is needed, creating another module might be a better option. --- buildSrc/src/main/kotlin/tasks.kt | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/buildSrc/src/main/kotlin/tasks.kt b/buildSrc/src/main/kotlin/tasks.kt index 3c8846cbd85..665be7240a1 100644 --- a/buildSrc/src/main/kotlin/tasks.kt +++ b/buildSrc/src/main/kotlin/tasks.kt @@ -88,8 +88,9 @@ fun Task.dependsOnKotlinGradlePluginPublish() { } } +// Mixing JUnit4 and Junit5 in one module proved to be problematic, consider using separate modules instead enum class JUnitMode { - JUnit4, JUnit5, Mix + JUnit4, JUnit5 } /** @@ -142,19 +143,6 @@ fun Project.projectTest( } } - val parentNames = if (jUnitMode != JUnitMode.JUnit4) { - /* - * If we run test from inner test class with junit 5 we need - * to include all containing classes of our class - */ - val nestedNames = classFileNameWithoutExtension.split("$") - mutableListOf(nestedNames.first()).also { - for (s in nestedNames.subList(1, nestedNames.size)) { - it += "${it.last()}\$$s" - } - } - } else emptyList() - include { treeElement -> val path = treeElement.path if (treeElement.isDirectory) { @@ -162,11 +150,7 @@ fun Project.projectTest( } else { if (path == classFileName) return@include true if (!path.endsWith(".class")) return@include false - when (jUnitMode) { - JUnitMode.JUnit4 -> path.startsWith("$classFileNameWithoutExtension$") - JUnitMode.Mix -> parentNames.any { path.startsWith(it) } || path.startsWith("$classFileNameWithoutExtension$") - else -> error("JUnit5 should not be reachable because of early exit") - } + path.startsWith("$classFileNameWithoutExtension$") } } }