Barry
Barry

Reputation: 1810

How to do remote debugging of tests?

I pass jvm debug flags to sbt on start

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9003

and see Listening for transport dt_socket at address: 9003 on startup.

I use remote debug config in IntelliJ IDEA and it always reports it's connected - Connected to the target VM, address: 'localhost:9003', transport: 'socket'.

I can debug via IntelliJ the main source code but I cannot successfully debug my ScalaTest unit tests. Why?

Upvotes: 2

Views: 933

Answers (1)

david.perez
david.perez

Reputation: 7012

The solution is as easy as using these settings:

fork in Test := true
javaOptions in Test := Seq("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9003
")

Beware that the JVM is suspended until I connect a debugger, so that we have enough time to connect a debugger. A breakpoint must be set before connecting.

Upvotes: 1

Related Questions