Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play! Framework 2.2.0 : impossible to debug in Eclipse

I'm trying to debug my unit tests with Eclipse (Kepler), in a Play! project. I launched play debug. In Eclipse, I created a Remote Java Application in Debug Configurations with the port supplied by the output of the command line. Clicked Apply, then Debug, added breakpoints. In the command prompt of my Play project, I launched test. Eclipse never stops at the breakpoints. It's very annoying. I'm on Windows 7 Pro 64bits.

Thanks for your help

like image 911
Pierre-Yves Le Dévéhat Avatar asked Oct 16 '13 08:10

Pierre-Yves Le Dévéhat


People also ask

How to debug Play framework Eclipse?

To debug, start your application with activator -jvm-debug 9999 run and in Eclipse right-click on the project and select Debug As, Debug Configurations. In the Debug Configurations dialog, right-click on Remote Java Application and select New. Change Port to 9999 and click Apply.

How do I debug an error in Eclipse?

To debug your application, select a Java file with a main method. Right-click on it and select Debug As Java Application. If you started an application once via the context menu, you can use the created launch configuration again via the Debug button in the Eclipse toolbar.


2 Answers

Add:

val main = play.Project(appName, appVersion, appDependencies).settings(
   // Add your own project settings here
   Keys.fork in (Test) := false
)

in your Build.scala as explained here

With command line in your Play! project:

  • play clean
  • play compile
  • play debug
  • (in eclipse) run your debug remote
  • test

I just test it in Keppler, works fine for me ;)

like image 79
Yannick Chartois Avatar answered Sep 21 '22 10:09

Yannick Chartois


Building on @Pierre-Yves' suggestion (I'm new to Play 2.2 and SBT, so this may be avoidable), to debug individual unit tests via IntelliJ I needed the following in build.sbt (thanks to Mike Slinn):

Keys.fork in Test := false

parallelExecution in Test := false

Without the build.sbt changes, executing the following in the Play debug console (each session) worked:

$ set sbt.Keys.fork in Test := false

After either of those solutions, I could then set breakpoints and remote debug individual test classes via:

$ test-only *package.class*
like image 22
Rick Avatar answered Sep 19 '22 10:09

Rick