使用GroovyShell加载的调试脚本(在eclipse中) [英] Debugging scripts loaded with GroovyShell (in eclipse)

查看:229
本文介绍了使用GroovyShell加载的调试脚本(在eclipse中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eclipse和groovy插件。我正在构建测试工具来调试和测试groovy脚本。这些脚本很简单但很长,其中大多数只是/ else / return。我发现我可以使用GroovyShell和Bindings调用它们来传递值。



问题是,虽然我可以调用脚本并获得结果,我不能用调试器进入那里。这些脚本中的断点不活动。



有没有办法调试脚本?也许我应该使用GroovyShell以外的东西?
我真的不想通过将脚本包装成函数来修改脚本,然后从我的测试类中调用这些函数。



这就是我正在使用的绑定和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));


解决方案

我猜你的脚本不在类路径的项目。您需要将它们添加到类路径中,最好确保包语句正确(或确保它们位于该源文件夹的默认目录中)。



您可以也想将此源文件夹指定为脚本文件夹。这将确保您的脚本未编译到输出文件夹。您可以通过首选项 - > Groovy - >编译器执行此操作。单击复选框以启用脚本文件夹,然后创建正则表达式以指定文件夹。您还可以指定脚本是否应按原样复制到输出文件夹。


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"));

解决方案

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.

这篇关于使用GroovyShell加载的调试脚本(在eclipse中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆