Created
October 8, 2019 07:10
-
-
Save olafurpg/3085a4b9e9635db22bbc10b01252deeb to your computer and use it in GitHub Desktop.
Example how to print summary of test failures with utest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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