How to read datasource in Parasoft using scripting

AkankshaAkanksha Posts: 3
edited October 2017 in SOAtest

Using script i want to read the values from datasource so that the same can be used across all TSTs.

Answers

  • Ireneusz SzmigielIreneusz Szmigiel Posts: 134 ✭✭
    edited October 2017

    Akanksha,

    you can use Global Data Source which allows you to use the same data source across all TSTs.
    Here is a simple Jython script which read column from data source called "Global" with column named "keyword":

        from com.parasoft.api import *
    
        def getDataSourceValue(input, context):
            # "value" is the value from the Data source at the specified column
            value = context.getValue("Global", "keyword")
            Application.showMessage("In DS we have:" + str(value))
    

    BTW: here is a good example how to get vale of particular row

  • AkankshaAkanksha Posts: 3

    Hi Ireneusz , Is it possible to achieve this using groovy scripting. Below is the script we are using:
    import static java.util.Calendar.*;
    import java.text.SimpleDateFormat;
    import javax.xml.datatype.XMLGregorianCalendar;
    import java.text.DateFormat;
    import java.util.regex.Pattern;
    import java.sql.Timestamp;
    import java.lang.*;
    import java.io.*;
    //def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);

    String path(){
    def sdf = new java.text.SimpleDateFormat("dd-MM-yyyy hh-mm-ss aa");
    def SysDate = sdf.format( new Date()) ;

    String runFolder = "C:/User/Run_" + SysDate;

    def runFolderDir= new File(runFolder);
    runFolderDir.mkdir();

    return runFolder;
    }

    I have tried below groovy script in SoapUI and able to call datasource but the same script is not working in Parasoft.
    def getstep = testRunner.testCase.getTestStepByName("Properties").getPropertyValue("FolderPath");
    log.info getstep;

    I need to know how this can be called in parasoft.
    Thanks in advance!

  • Ireneusz SzmigielIreneusz Szmigiel Posts: 134 ✭✭

    Akanksha

    I think that soapUI script will not work as you are using part of soapUI api.
    Did you check thread which I mentioned at the end of my post?
    There is an example in Groovy:

    import com.parasoft.api.*;
    
    public String getFifth(ScriptingContext context)
    {
        return context.getValues("New Datasource", "test").get(4);
    }
    

    What do you want to do:
    -open datasource defined/exist in SOAtest project?
    -open external file in SOAtest as datasource?

  • AkankshaAkanksha Posts: 3

    I want to read values defined in datasource in Parasoft SOA Project

  • Ireneusz SzmigielIreneusz Szmigiel Posts: 134 ✭✭

    Then you can use steps described in this topic.

Sign In or Register to comment.