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.

How to use a runtime parameter in groovy

Anmol_Gupta
Anmol_Gupta Posts: 1

I am using a groovy script in which I want a to enter a parameter in the method at the runtime.

For e.g. : def userId(String input) {

//my method
}

How can I derive the input variable while I try to run the API test case

Answers

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭
    edited May 2020

    If you are using an Extension Tool, your method must take 0, 1, or 2 arguments where the first is the input to the tool and the second is a com.parasoft.api.ScriptingContext. So, if you want your script to read the text from the input to the Extension tool then use the first argument. If you want to read other types of parameters, like data source columns, data bank columns, test variables, environment variables, etc. then call the appropriate methods on the ScirpingContext object. The SOAtest Help dialog includes the javadocs for classes in com.parasoft.api. There are also various examples in the user's guide under Extensibility and Scripting Basics.