Debug scripts loaded by GroovyShell (in eclipse)

I work with connecting eclipse and groovy. I am creating a test harness for debugging and testing groovy scripts. The scripts are really simple, but long, most of them are simple if / else / return. I realized that I could call them using GroovyShell and Bindings to pass values.

The problem is that although I can call the script and get the results just fine, I CANNOT step there with the debugger. Breakpoints are inactive in these scenarios.

Is there any way to debug scripts? Maybe I should use something other than GroovyShell? I really do not want to modify the scripts by transferring them to functions and then calling these functions from my test classes.

The way I use Binding and GroovyShell:

def binding = new Binding(); binding.lineList = [list1]; binding.count = 5; def shell = new GroovyShell(binding); def result = shell.evaluate(new File("src/Rules/checkLimit.groovy")); 
+2
source share
1 answer

I assume your scripts are not on the way to the class of your project. You need to add them to the class path and, preferably, make sure that the package instructions are correct (or make sure that they are in the default directory for this source folder).

You can also specify this source folder as a script folder. This ensures that your scripts will not be compiled to the output folder. You can do this through Preferences -> Groovy -> Compiler. Check the box to include script folders, and then create a regular expression to specify the folder. You can also specify whether scripts should be copied as is in the output folder.

+4
source

All Articles