4

I am working with eclipse and groovy plug in. I am building a test harness to debug and test groovy scripts. The scripts are really simple but long, most of them just if/else/return. I figured out that I can call them using GroovyShell and Bindings to pass in the values.

The problem is that, while I can call the script and get the results just fine, I CAN NOT step in there with the debugger. Breakpoints in those scripts are not active.

Is there a way to debug the scripts? Maybe I should use something other than GroovyShell? I really don't want to modify the scripts by wrapping them into functions, and then calling those functions from my test classes.

That's how I am using 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"));
user229044
  • 232,980
  • 40
  • 330
  • 338
MSh
  • 43
  • 3

1 Answers1

6

I am guessing that your scripts are not on the classpath of your project. You need to add them to the classpath and preferably make sure that package statements are correct (or make sure they are in the default directory for that source folder).

You may also want to designate this source folder as a script folder. This will ensure that your scripts are not compiled to the output folder. You can do this through Preferences -> Groovy -> Compiler. Click the checkbox to enable script folders and then create the regex to specify the folder. You can also specify whether or not the scripts should be copied over as-is to the output folder.

Andrew Eisenberg
  • 28,387
  • 9
  • 92
  • 148
  • Thank you. Yes, that was the problem - I had to put the scripts into source folder, or add "package Rules" in each script. – MSh Jan 31 '11 at 16:23