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.

Can you use a Test Scenario variable in a test script?

Options

I have a variable in a test scenario that gets set from a REST call's response using an XML databank (variable is named x and gets set to the number of widgets). I would like to then perform an operation on that widget that requires the use of a groovy script (this operation accesses a row in a writable datasource and the script tells it which row and column to use). I would like to not hardcode the row number but use the variable x in the groovy script. I plan to have a loop in the test scenario that decrements x after each run therefore grabbing a different row for each time the test is run in the loop (row 37, row 36, row 35 .... until 0). The current groovy script is as follows:

import com.parasoft.api.*;

public String getWidget(ScriptingContext context)
{
return context.getValues("datasourceName", "columnName").get(37);
}

Can I do something like this?

return context.getValues("datasourceName", "columnName").get("${x}");.

Thanks again.

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,230 ✭✭✭
    Options

    See com.parasoft.api.ScriptingContext.getValue(String variableName)
    Javadoc says "This function returns the value of the TestSuiteVariable named variableName"

  • BrianQuantum
    Options

    Thank you