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.

How to take values from xml or json data banks into groovy scripts.

Options
Navsid
Navsid Posts: 2

Im trying to take the values from data bank into script but getting error can anyone help me out.

Answers

  • Ireneusz Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭
    Options

    Hi Navsid,

    what error do you see?
    Usually it should be straight forward like is described in User Manual
    See section Accessing Data Sources from Scripts.
    You can find a couple examples on this forum

    --
    Ireneusz Szmigiel
    http://www.catb.org/esr/faqs/smart-questions.html

  • Navsid
    Navsid Posts: 2
    Options

    Hi how to take key from xml and json data banks into groovy scripts. And perfrom operations on that values and need to pass a specific value to next test.

  • jakubiak
    jakubiak Posts: 798 admin
    Options

    In the script, the method needs to define the context object, and then it needs to call getValue() on that context like in the following example, where "dataBankColumnName" is the name of the data bank column you defined:

    import com.parasoft.api.*;
    
    public void doSomething(Context context) {
        context.getValue("Generated Data Source", "dataBankColumnName")
    }
    

    I just typed up this example quickly without testing it, so it may take some tweaks to make it work if I have a typo.