First of all you need to download DB driver, e.g. ojdbc7.jar and place it in binext folder of dir:

C:Program Files (x86)SmartBearSoapUI-5.3.0binext

Then you can use groovy script to create connection to DB, query test values and assign it to SoapUI parameter:

import groovy.sql.Sql 
import com.eviware.soapui.support.GroovyUtils

log.info("")
log.info("  init DB connection...")

def scriptServer = "db.db.test.db.db.ru"
def scriptPassword = "password"
def scriptSid = "oraSid"
def scriptUsername = "dbUser"
def scriptDBport = "1111"

com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("oracle.jdbc.driver.OracleDriver")
sql = Sql.newInstance("jdbc:oracle:thin:@${scriptServer }:${scriptDBport}:${scriptSid}", "${scriptUsername}", "${scriptPassword}", "oracle.jdbc.OracleDriver") 

def queryUserId= "" +
"select userId from " +
"  (select userId from " +
"  users_table " +
"  where age between 21 and 80 and driver_licence = 1"
"  order by dbms_random.value) " +
"where rownum = 1"

def res = sql.firstRow(queryUserId)
def user_id = res[0].toString()

testRunner.testCase.setPropertyValue( "user_id" , user_id)

sql.close()

And then use these variables (as SoapUI castom properties) in of requests & assertions of responses:

<ServiceProperties>
   <UserId>${#TestCase#user_id}</UserId>
</ServiceProperties>



Source link https://sqa.stackexchange.com/questions/26125/how-to---from-soapui-for-test-data-generation

LEAVE A REPLY

Please enter your comment!
Please enter your name here