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?
2 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 = {}
}
-
1If you can reduce the breakpoint problem to a reproducible test case, we will like to know about it: http://scala-ide.org/docs/community.html. – skyluc Mar 21 '13 at 05:52
-
Good point as soon as I have some time I will try to make an isolated test case – EECOLOR Mar 21 '13 at 07:20
-
And make sure to use the latest Scala IDE release (at the time of this writing, v3.0.0) – Mirco Dotta Mar 23 '13 at 17:01
Using the Scala debugger
through the remote connector works.
But if you want to avoid to go back and forth between sbt
and Eclipse
, you can load your project in Scala IDE
using sbteclipse, and then run your specs2 tests from inside Scala IDE
, in debug mode, using the JUnit launcher.
- 640
- 4
- 6
-
I use sbteclipse, really nice! The JUnit launcher would not be a good choice here because I am using [Auto Examples](http://etorreborre.github.com/specs2/guide/org.specs2.guide.Structure.html#Auto-Examples) that are longer than one line. – EECOLOR Mar 21 '13 at 07:19