简体   繁体   中英

Play Framework 2.1 debug subproject unit tests with Eclipse

No problems debugging my Play webapp with eclipse debugger, but have been unsuccessful in getting the debugger to engage during unit tests. I have tried the suggestions listed here and here but when I connect my debugger through Eclipse, my break points are still getting ignored.

My webapp consists of two subprojects and I have added the setting:

Keys.fork in (Test) := false

to all three Build.scala files in the play.Project(...).settings section: both of my subprojects as well as the one the one at the top level. I then do the following:

  1. from the play console, run play clean
  2. from the play console, run play compile
  3. from the play console, run play debug
  4. from Eclipse, run debug configuration looking at port 9999 (same one I use to debug webapp successfully)
  5. at the play $ prompt, run test

Are there additional steps to take when debugging tests that part of a subproject or if using fakeApplication (I'm doing model testing with an in-memory db)?

In the top level build.scala file there were three lines that looked like this:

val proj1 = play.Project(appName + "-Proj1", appVersion, proj1Dependencies, path = file("subprojects/Proj1") )

val proj2 = play.Project(appName + "-Proj2", appVersion, proj2Dependencies, path = file("subprojects/Proj2") )

val main = play.Project(appName,      appVersion, mainDependencies).settings(
// Add your own project settings here)
).dependsOn( proj1, proj2 ).aggregate( proj1, proj2 )

I was wanting to debug unit tests in proj2, so I needed to add the new setting there like so:

val proj2 = play.Project(appName + "-Proj2", appVersion, proj2Dependencies, path = file("subprojects/Proj2") ).settings(
Keys.fork in (Test) := false

)

Note: In this example, all three dependency variables: mainDependencies, proj1Dependencies, and proj2Dependencies point to the same base dependencies that look like this:

val baseDependencies = Seq(
javaCore,
javaJdbc,
javaEbean,
"xom" % "xom" % "1.2.5",
"net.sf.json-lib" % "json-lib" % "2.4" classifier "jdk15"

)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM