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:
- Start grails in a terminal with: grails-debug -reloading -Dvar=blah
- Start remote debugger in Intellij
- 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:
- Run individual spock integration tests from the grails interactive console (I don't want to restart the whole grails environment for every test)
- Pass system properties to grails on the command line
- Debug those tests in Intellij
- 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)