Skip to content

Instantly share code, notes, and snippets.

@olafurpg
Created October 8, 2019 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olafurpg/3085a4b9e9635db22bbc10b01252deeb to your computer and use it in GitHub Desktop.
Save olafurpg/3085a4b9e9635db22bbc10b01252deeb to your computer and use it in GitHub Desktop.
Example how to print summary of test failures with utest
override def utestFormatter: Formatter = new Formatter {
import utest.framework._
import utest.ufansi
override def formatSummary(
topLevelName: String,
results: HTree[String, Result]
): Option[ufansi.Str] = Some {
val summary = results match {
case HTree.Node(_, c @ _*) =>
c.collect {
case Leaf(result) if result.value.isFailure =>
List(topLevelName, result.name)
.mkString(ufansi.Color.Red("X ").toString(), ".", "\n") +
result.value.asInstanceOf[Failure[_]].exception.toString()
}
.mkString("\n")
case HTree.Leaf(r) =>
""
}
if (summary.nonEmpty) {
println("==========")
println("= Failures")
println("==========")
println(summary)
}
summary
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment