In my code I have the following exception
class HttpRequestException(val response: HttpResponse) extends Throwable {
...
override def toString: String = {
s"Received unexpected status code. \n Status Code: [${response.status}] \n Body: $body \n Headers: $headers"
}
}
In my tests, there are cases where this can be thrown. When I run the tests from IntelliJ and this exception is hit, the output looks like...
com.twitter.dataproducts.clients.http.HttpRequestException was thrown.
Received unexpected status code.
Status Code: [422 Unprocessable Entity]
Body: ....
Headers:
Date: Tue, 22 Nov 2016 20:06:48 GMT
...
at com.twitter.dataproducts.clients.akka.Flows$$anonfun$checkResponseForError$1.apply(Flows.scala:25)
at com.twitter.dataproducts.clients.akka.Flows$$anonfun$checkResponseForError$1.apply(Flows.scala:22)
at akka.stream.impl.fusing.Map$$anon$8.onPush(Ops.scala:42)
This information is super useful in debugging exactly what went wrong.
Now when I run this same test from my command line using "-o" for the stdout reporter, all I end up getting is...
- test that failed *** FAILED ***
com.twitter.dataproducts.clients.http.HttpRequestException:
at com.twitter.dataproducts.clients.akka.Flows$$anonfun$checkResponseForError$1.apply(Flows.scala:25)
at com.twitter.dataproducts.clients.akka.Flows$$anonfun$checkResponseForError$1.apply(Flows.scala:22)
at akka.stream.impl.fusing.Map$$anon$8.onPush(Ops.scala:43)
As you can see, the all that useful information is gone. Base on the ":" trailing the exception type, I am guessing that I am just doing something wrong to get this to print out in that reporter.
I also cannot specifically use an info() in the test as I am building up a framework for other devs to use, so setting this up to print behind the scenes is important.
As a note, I am using scalatest 3.0.