All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.kotest.assertions.MultiAssertionError.kt Maven / Gradle / Ivy

package io.kotest.assertions

import io.kotest.mpp.throwableLocation

/** An error that bundles multiple other [Throwable]s together */
class MultiAssertionError(errors: List) : AssertionError(createMessage(errors)) {
  companion object {
    private fun createMessage(errors: List) = buildString {
      append("\nThe following ")

      if (errors.size == 1) {
        append("assertion")
      } else {
        append(errors.size).append(" assertions")
      }
      append(" failed:\n")

      for ((i, err) in errors.withIndex()) {
        append(i + 1).append(") ").append(err.message).append("\n")
        err.throwableLocation()?.let {
          append("\tat ").append(it).append("\n")
        }
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy