[Native][tests] Remove unnecesary common prefix in dynamic test names
This commit is contained in:
+11
-9
@@ -68,22 +68,24 @@ abstract class AbstractNativeBlackBoxTest {
|
||||
* This function should be called from a method annotated with [org.junit.jupiter.api.TestFactory].
|
||||
*/
|
||||
internal fun dynamicTestCase(testCaseId: TestCaseId): Collection<DynamicNode> {
|
||||
val rootTestRunNode = testRunProvider.getTestRuns(testCaseId)
|
||||
return buildJUnitDynamicNodes(rootTestRunNode)
|
||||
val testRunNodes = testRunProvider.getTestRuns(testCaseId)
|
||||
return buildJUnitDynamicNodes(testRunNodes)
|
||||
}
|
||||
|
||||
// We have to use planar (one-level) tree of JUnit5 dynamic nodes, because Gradle does not support yet rendering
|
||||
// tests with arbitrary nesting level in their test reports. As long as these reports are consumed by various CI (such as TeamCity)
|
||||
// we have almost no chance to display test results in CI properly.
|
||||
private fun buildJUnitDynamicNodes(testRunNode: TreeNode<TestRun>): Collection<DynamicNode> =
|
||||
private fun buildJUnitDynamicNodes(testRunNodes: Collection<TreeNode<TestRun>>): Collection<DynamicNode> =
|
||||
// This is the proper implementation that should be used instead:
|
||||
// buildList {
|
||||
// testRunNode.items.mapTo(this) { testRun ->
|
||||
// dynamicTest(testRun.displayName) { runTest(testRun) }
|
||||
// }
|
||||
// testRunNodes.forEach { testRunNode ->
|
||||
// testRunNode.items.mapTo(this) { testRun ->
|
||||
// dynamicTest(testRun.displayName) { runTest(testRun) }
|
||||
// }
|
||||
//
|
||||
// testRunNode.children.mapTo(this) { childTestRunNode ->
|
||||
// dynamicContainer(childTestRunNode.packageSegment, buildJUnitDynamicNodes(childTestRunNode))
|
||||
// testRunNode.children.mapTo(this) { childTestRunNode ->
|
||||
// dynamicContainer(childTestRunNode.packageSegment, buildJUnitDynamicNodes(childTestRunNode))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
buildList {
|
||||
@@ -97,7 +99,7 @@ abstract class AbstractNativeBlackBoxTest {
|
||||
children.forEach { it.processItems(ownPackageSegment) }
|
||||
}
|
||||
|
||||
testRunNode.processItems("")
|
||||
testRunNodes.forEach { testRunNode -> testRunNode.processItems("") }
|
||||
}
|
||||
|
||||
private fun performTestRun(testRun: TestRun) {
|
||||
|
||||
+3
-1
@@ -98,7 +98,9 @@ internal class TestRunProvider(
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
fun getTestRuns(testCaseId: TestCaseId): TreeNode<TestRun> = withTestExecutable(testCaseId) { testCase, executable, cacheKey ->
|
||||
fun getTestRuns(
|
||||
testCaseId: TestCaseId
|
||||
): Collection<TreeNode<TestRun>> = withTestExecutable(testCaseId) { testCase, executable, cacheKey ->
|
||||
fun createTestRun(testRunName: String, testFunction: TestFunction?): TestRun {
|
||||
val runParameters = getRunParameters(testCase, testFunction)
|
||||
return TestRun(testRunName, executable, runParameters, testCase.id)
|
||||
|
||||
+11
-5
@@ -15,15 +15,15 @@ internal interface TreeNode<T> {
|
||||
companion object {
|
||||
fun <T> oneLevel(vararg items: T) = oneLevel(listOf(*items))
|
||||
|
||||
fun <T> oneLevel(items: Iterable<T>) = object : TreeNode<T> {
|
||||
fun <T> oneLevel(items: Iterable<T>): List<TreeNode<T>> = listOf(object : TreeNode<T> {
|
||||
override val packageSegment get() = ""
|
||||
override val items = items.toList()
|
||||
override val children get() = emptyList<TreeNode<T>>()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T, R> Collection<T>.buildTree(extractPackageName: (T) -> PackageFQN, transform: (T) -> R): TreeNode<R> {
|
||||
internal fun <T, R> Collection<T>.buildTree(extractPackageName: (T) -> PackageFQN, transform: (T) -> R): Collection<TreeNode<R>> {
|
||||
val groupedItems: Map<PackageFQN, List<R>> = groupBy(extractPackageName).mapValues { (_, items) -> items.map(transform) }
|
||||
|
||||
// Fast pass.
|
||||
@@ -44,8 +44,14 @@ internal fun <T, R> Collection<T>.buildTree(extractPackageName: (T) -> PackageFQ
|
||||
node.items += items
|
||||
}
|
||||
|
||||
// Skip meaningless nodes starting from the root. Compress the resulting tree.
|
||||
return root.skipMeaninglessNodes().apply { compress() }
|
||||
// Skip meaningless nodes starting from the root.
|
||||
val meaningfulNode = root.skipMeaninglessNodes().apply { compress() }
|
||||
|
||||
// Compress the resulting tree.
|
||||
return if (meaningfulNode.items.isNotEmpty() || meaningfulNode.childrenMap.isEmpty())
|
||||
listOf(meaningfulNode)
|
||||
else
|
||||
meaningfulNode.childrenMap.values
|
||||
}
|
||||
|
||||
private class TreeBuilder<T>(override var packageSegment: String) : TreeNode<T> {
|
||||
|
||||
Reference in New Issue
Block a user