Forum Discussion

RJanecek's avatar
RJanecek
Regular Contributor
16 years ago

sharing value in groovy script

Hi,
My first testStep is groovy script where I read integer value from external source then I run test request where I send some data to external source. Then I create another groovy script where I want to compare value from first groovy script but I dont know how to read value from first groovy script. So can you help me with this problem please ?

5 Replies

  • Beno_Iskratel's avatar
    Beno_Iskratel
    Frequent Contributor
    if nothing else you can probably create "PropertiesTestStep" and save data there or just into properties of your Testcase.
    not the best option, but i it shall work.
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    yea now I use method setPropertyValue that has two parameters both string. So firstly I must convert int to string than create property then in second groovy script a read this value and convert it to the integer, this work but I looking for some more simply and better solution.
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    Hi again,
    now I need to share sql instance. Is it possible ? In setup script I want to establish connection and in test step just want to use this variable.
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    I have following steps in my Single Testcase.

    Data source
    Create operation
    DB Checker
    Get operation
    Datasource Loop


    I'm using Data source to fectch values from DB and feeding to my Create operation

    And then doing Groovy script step to verify values fetched from DB

    fetching of one of my response value from Create operation and feeding to get operation

    Looping above 3 steps through Datasource loop step


    Now, I want to create a setup script where I want to intialize DB connection. Since I do not want to open and close DB connection for every of my testcase. I tried placing following piece of code in setup script tab. However, while running my DB_Checker step, UI complains that it could NOT find property sql which is defined in setup script. ANY help will be useful
     import groovy.sql.Sql;
    def MA_UUID;
    def ERR_MESSAGE = "DATABASE MISMATCH ";
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );

    def sql = Sql.newInstance("jdbc:db2://IP_ADDRESS:60000/DB_NAME", "USERNAME","PASWORD", "com.ibm.db2.jcc.DB2Driver");