Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

groovy autocomplete and calling other groovy scripts

Urs
Urs Posts: 13

hi
is there any way to use the autocomplete (ctrl+space) functionality for the language groovy in external tools?
i would like to be able to e.g. see the available methods and attributes of used java classes or my own groovy classes while i code.

and is there a guide on how to setup SOAtest (9.10) so i can import groovy scripts from another groovy script?
e.g. jython has a jython home which is searched vor .py scripts. with a simple 'import module_name' I can get jython scripts within other jython scripts.
how does this work for groovy?

thank you

Tagged:

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited June 2021

    is there any way to use the autocomplete (ctrl+space) functionality for the language groovy in external tools?

    You mean "Extension tools", right? Scripted fields in SOAtest Extension tools or scripted fields in test/tool editors only provide minimal syntax coloring for Groovy but no autocomplete. However, I believe there are plugins available that provide an IDE for Groovy. I personally haven't tried this one but I just searched the Eclipse marketplace and found GGTS

    so i can import groovy scripts from another groovy script

    I recall being able to add groovy scripts to the classpath and that Groovy will find them automatically, no different than adding java libraries (.jar files) to the classpath. In SOAtest, click "Parasoft> Preferences...> System Properties" then add the desired .groovy files to the Classpath table. In your SOAtest Extension tool or scripted field, you can import Groovy classes from .groovy script files similar to importing Java classes from .class files. Refer to the Groovy docs for how to write modular code with packages, classes, and imports:
    http://groovy-lang.org/structure.html
    http://groovy-lang.org/objectorientation.html

    However, to make your scripts load faster, I recommend compiling your groovy scripts to java bytecode (.class files) then adding the directory containing the .class files to the Classpath table I mentioned. Use groovyc to compile your groovy scripts. Adding groovy source files is slower than compiled bytecode because Groovy has to evaluate the scripts on the classpath for each script in your SOAtest test suite that may be using them. An IDE like the one I mentioned may also help automate compilation to java byte code in addition to other things like providing editors with autocomplete.