Is there something in Scalatest that will allow me to test the output to the standard out via a println statement?
So far I’ve mainly been using FunSuite with ShouldMatchers.
e.g. how do we check the printed output of
object Hi {
def hello() {
println("hello world")
}
}
The usual way to test print statements on the console is to structure your program a bit differently so that you can intercept those statements. You can for example introduce an
Outputtrait:And in your tests you can define another trait
MockOutputactually intercepting the calls: