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.

Incremented test variable

asingh Posts: 14

I have a test variable which stores value from Text data Bank , how can I use the incremented value of variable in my test case.



  • jakubiak
    jakubiak Posts: 798 admin

    You should be able to write a simple script that increments the value. Can you provide more details about where the variable is being used: what kind of test it is, where in the UI you are inputting the variable? This will help guide any suggestions about where to put the script.

  • asingh
    asingh Posts: 14

    I am trying with script

    import com.parasoft.api.*;
    def incrementSerialId(ScriptingContext scriptContext) {
    //return iSerial;

    however it is giving me below error

    Error during script execution. View Details for more information.

        No signature of method: Script596.incrementSerialId() is applicable for argument types:
         (webtool.packet.ScriptingFriendlyTextUsable) values: [3633
        Possible solutions: incrementSerialId(com.parasoft.api.ScriptingContext)

  • jakubiak
    jakubiak Posts: 798 admin

    In your example I am assuming that "iSerial" is the name of the data source column that you defined within the Text Data Bank. If so, you cannot write back into that data bank column with a script. Instead, you should define a variable within the test suite, and then set the incremented value into the variable instead of trying to update the data bank value. Also, you are having problems since the signature of your method needs to contain two input parameters if you want to get the ScriptingContext - you can see what signature to use by clicking the "Expected number of arguments" link at the bottom of the Extension Tool editor. The code would look like this:

    import com.parasoft.api.*;
    def incrementSerialId(Object input, ScriptingContext scriptContext) {
        // iSerial is the name of the column name as defined in the Text Data Bank
        iSerial=scriptContext.getValue("Generated Data Source", "iSerial").toInteger()+1;
        // myVar is the name of a variable defined in the Variable section of the Test Suite