This topic explains how to create and apply an Extension tool. The tool performs custom operations written in Java, JavaScript, Oracle Nashorn, Groovy, Jython, or other scripting engines that implement the JSR 223 "Scripting for the Java Platform" specification.
Sections include:
The Extension tool allows you to implement a custom operation independently or in conjunction with your existing test suite. This additional functionality gives you the ability to customize SOAtest to your specific needs and is limited only by the capabilities of the scripting language that you are working with. The scripts may accept zero, one, or two arguments. The source of the output can be a derived from a client request, a server response, the output of another tool, an element of a rule, or it can be user defined beforehand. This is useful if you want to perform application-specific checks that cannot be expressed with a rule (for example, if you want to check if a given output matches a record in a database). Or you can design the script to perform any specific function that would be helpful to you.
If your method accepts zero arguments, then it does not matter what file is selected when it is run. If the method accepts one argument, then the input will be taken from the file selected or the tool to which it is attached. If the method accepts two arguments, then the first will be taken from the file or preceding tool and the second will take contextual information about the file. For more information on the types of context arguments that can be applied, go to Parasoft > Help > Scripting API. You can also create scripts that execute each time you start SOAtest. To do this, create a Jython or JavaScript script, then add it to the <INSTALL_DIR>/plugins/com.parasoft.ptest.libs.web_<VERSION>/root/startup
directory.
The following procedure describes how to add an Extension tool to the toolbar. You can also create custom methods in a test suite (in SOAtest) or Responder suite (in Virtualize) by adding an Extension tool, then completing the same parameters in the Extension parameters panel.
To add a custom script/Extension tool to SOAtest or Virtualize:
Add an Extension tool using one of the techniques described in End-to-end Test Scenarios.
If a return value for this tool indicates the tool’s success, enable Exit code indicates success. If this option is not enabled, the return value of the method is ignored regardless of whether the tool succeeded or failed.
For other scripts, you can use an existing file as the source of code for your method or you can create the method in the UI.
To create the method in the UI from scratch, enable Text and enter your code in the associated text window.
To check that the specified script is legal and runnable, right-click the File or Text field (whichever one you used to specify your script) and choose Evaluate. Any problems found will be reported.
If your script returns content that contains For example, assume that your original script has:
To prevent
|
For an overview of issues related to the scripting feature and its various applications, see Extensibility and Scripting Basics.For a step-by-step demonstration of how to apply custom scripting in SOAtest, see Extending SOAtest with Scripting.