Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a stack trace from SBT with Scala

Context: Writing Scala unit-tests in a project managed by SBT.

When I execute sbt test to run my unit-tests an assert fails somewhere in my code, I get something like the following (and nothing more):

Test com.reach.ml.test.TestLSHEasy.T0 failed: assertion failed

This tells me which unit-test caused the assert fail, but not which assert it was. If I run the same test directly (not using sbt), I get a whole stack trace, which is very useful for debugging. So my question: How do I get SBT to print out the stack trace when a test crashes?

like image 429
emchristiansen Avatar asked Nov 05 '22 15:11

emchristiansen


1 Answers

Regarding xsbt, it might be related to the util.log.StackTrace object which can trim its output.
The issue 118 illustrated the will of keeping stack traces should be under better control:

so you shouldn't see that trace by default.

Maybe you can wrap your unit test, intercepting any exception, and printing explicitely their full stack trace? (as in Basic.scala or Boot.scala).

like image 119
VonC Avatar answered Nov 15 '22 05:11

VonC