From 1407af63011cf90efa42ae5f532cb08dffb83441 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 11 May 2021 17:01:48 +0300 Subject: [PATCH] [Test] Sort failed exceptions in JUnit5Assertions.assertAll This is needed to throw FileComparisonFailure first, because idea test UI can not show multiple diff windows for multiple assertions and shows only first, which is not useful --- .../jetbrains/kotlin/test/services/JUnit5Assertions.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/JUnit5Assertions.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/JUnit5Assertions.kt index 502f7ce638a..62d566bad34 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/JUnit5Assertions.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/JUnit5Assertions.kt @@ -54,7 +54,7 @@ object JUnit5Assertions : AssertionsService() { override fun assertAll(exceptions: List) { exceptions.singleOrNull()?.let { throw it } - JUnit5PlatformAssertions.assertAll(exceptions.map { Executable { throw it } }) + JUnit5PlatformAssertions.assertAll(exceptions.sortedWith(FileComparisonFailureFirst).map { Executable { throw it } }) } override fun assertNotNull(value: Any?, message: (() -> String)?) { @@ -68,4 +68,10 @@ object JUnit5Assertions : AssertionsService() { override fun fail(message: () -> String): Nothing { org.junit.jupiter.api.fail(message) } + + private object FileComparisonFailureFirst : Comparator { + override fun compare(o1: Throwable?, o2: Throwable?): Int { + return if (o1 is FileComparisonFailure) -1 else 0 + } + } }