Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Eclipse to debug tests driven by sbt?

I have a set of test cases that I want to debug (step by step, reading values, etc.). How can I setup my sbt build so that I can hookup an eclipse debugger?

like image 524
EECOLOR Avatar asked Mar 19 '13 22:03

EECOLOR


1 Answers

I found a way to attach the Eclipse debugger. To the Build.scala project settings I add the following options:

//required for the javaOptions to be passed in
fork := true

javaOptions in (Test) += "-Xdebug"

javaOptions in (Test) += "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

Then in Eclipse I can create a new Debug configuration (arrow next to the bug icon) of type Remote Java Application. There I can select Scala debugger (Socket Attach) and specify the port 5005.

Problem I now have is that I cannot set any breakpoints, but that's another question and might be related to the version of Scala IDE that I use.

Edit

Problems with setting the breakpoint had (most likely) something to do with the exotic constructions in my specs2 specification. I created a small object with a method in order to be able to set a breakpoint

object BreakPoint { 
  def set = {}
}
like image 102
EECOLOR Avatar answered Oct 11 '22 21:10

EECOLOR