[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
This commit is contained in:
committed by
TeamCityServer
parent
2530ae6b3d
commit
1407af6301
+7
-1
@@ -54,7 +54,7 @@ object JUnit5Assertions : AssertionsService() {
|
||||
|
||||
override fun assertAll(exceptions: List<Throwable>) {
|
||||
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<Throwable> {
|
||||
override fun compare(o1: Throwable?, o2: Throwable?): Int {
|
||||
return if (o1 is FileComparisonFailure) -1 else 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user