简体   繁体   中英

SoapUI - How to connect database and prepare data before load test?

Recently I've discovered that you can make a JDBC request Test Step in SoapUI ( doc 1 , doc 2 ). And I have a load test that fails under certain conditions, ie I need to manually execute SQL script in order to prepare data each time before I run this load test.

I'm not sure that it's possible, but if it is, how can I automate my initialization step?

ps. If I simply add JDBC Request test step to the load test then this step executes multiple times and this is not what I want. I think I need to query database from setup script:

在此处输入图片说明

Possible, Setup Script will be run before test is executed - for example you can set a groovy script like:

import groovy.sql.Sql

// db connection 
def DBurl = 'jdbc:oracle:thin:@11.111.1.11:1521:SID'
def DBuser = 'user'
def DBpassword = 'password'
def DBdriver = 'oracle.jdbc.pool.OracleDataSource'
def DBsql = Sql.newInstance(DBurl, DBuser, DBpassword, DBdriver)


// your sql
try{
DBsql.execute('''
[SQL U WANT TO EXECUTE]
''' ) 
} catch (Exception e) {
log.error  e.getMessage()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM