Printer

munit.diff.Printer
See thePrinter companion object
trait Printer

Implement this trait to customize the default printer

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object EmptyPrinter

Members list

Value members

Abstract methods

Concrete methods

def height: Int
def isMultiline(string: String): Boolean
def orElse(other: Printer): Printer

Combine two printers into a single printer.

Combine two printers into a single printer.

Order is important : this printer will be tried first, then the other printer. The new Printer's height will be the max of the two printers' heights.

Example use case : define some default printers for some types for all tests, and override it for some tests only.


case class Person(name: String, age: Int, mail: String)

trait MySuites extends FunSuite {
 override val printer = Printer.apply {
   case Person(name, age, mail) => s"$name:$age:$mail"
   case m: SomeOtherCaseClass => m.someCustomToString
 }
}

trait CompareMailsOnly extends MySuites {
 val mailOnlyPrinter = Printer.apply {
   case Person(_, _, mail) => mail
 }
 override val printer =  mailOnlyPrinterPrinter orElse super.printer
}

Attributes