1

I'm trying to debug my spock tests using the following method, which used to work in Grails 2.3, but no longer does in 2.4.4:

  1. Start grails in a terminal with: grails-debug -reloading -Dvar=blah
  2. Start remote debugger in Intellij
  3. Rejoice as I can run tests from the grails console, debug them, modify services and have them auto-reloaded.

Since grails 2.4, the grails-debug script is gone, replaced with grails -debug. But what I've found is that -debug only works if it's the first argument, and then it ignores the -reloading argument. And while changes to the test itself is reloaded, changes to services that the test uses are not. So I can debug without reloading. If -reloading is the first argument, then reloading of services works, but I can no longer debug. All of the above using non-forked execution.

An added complication for forked execution is that I need to pass -Dvar=blah to my app, and there doesn't seem to be a mechanism to do this with forked exec. So I've disabled forked exec by commenting out the section in BuildConfig.groovy entirely:

grails.reload.enabled = true
//forkConfig = [maxMemory: 1024, minMemory: 64, debug: true, maxPerm: 256]
//grails.project.fork = [
//        test: forkConfig, // configure settings for the test-app JVM
//        run: forkConfig, // configure settings for the run-app JVM
//        war: forkConfig, // configure settings for the run-war JVM
//        console: forkConfig // configure settings for the Swing console JVM
//]

and also tried:

grails.reload.enabled = true
forkConfig = [maxMemory: 1024, minMemory: 64, debug: true, maxPerm: 256]
grails.project.fork = [
        test: false, // configure settings for the test-app JVM
        run: false, // configure settings for the run-app JVM
        war: false, // configure settings for the run-war JVM
        console: false // configure settings for the Swing console JVM
]

In neither case, can I both debug tests and have them reload services at the same time.

My question is: With Grails 2.4.4 and Intellij ultimate 13.1.5 how can do all of the below at the same time:

  1. Run individual spock integration tests from the grails interactive console (I don't want to restart the whole grails environment for every test)
  2. Pass system properties to grails on the command line
  3. Debug those tests in Intellij
  4. Make changes to services and have them automatically reload

(I'd be happy to use forked exec if that's what solves this, but then need a mechanism to pass properties to the forked debug session)

stephendv
  • 11
  • 2
  • Did you try with "run-app --debug-fork" and the remote debugger?? – agusluc Dec 01 '14 at 18:38
  • "run-app --debug-fork" works fine, but I don't want to run the app, I want to run individual tests from the interactive grails session like: test-app MySpecialService – stephendv Dec 02 '14 at 10:08
  • Maybe this is related: http://stackoverflow.com/questions/18882589/grails-2-3-0-auto-reloading-not-working – Pablo Pazos Jun 01 '15 at 03:00

0 Answers0