溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

soapUI+groovy 接口測試之部分groovy使用記錄

發(fā)布時(shí)間:2020-07-27 12:59:04 來源:網(wǎng)絡(luò) 閱讀:1628 作者:chinewwen 欄目:數(shù)據(jù)庫

1, 寫入值(30,31),更新到數(shù)據(jù)表的多條記錄。


sqlStr ="select column_id from 1dcq_shop_column2  where shop_id = '"+ db_Shop_id + "'"

def dbSettings=[]

def db_sub_column_id =""

sqlResult = sql.eachRow(sqlStr)

{

dbSettings << it.toRowResult() 

}

 

for (i=0;i< dbSettings.size;i++)

{

db_sub_column_id = db_sub_column_id.toString() + dbSettings[i].column_id.toString()

if (i < dbSettings.size-1)

{

db_sub_column_id=db_sub_column_id+","

}

}

assert subColumnId == db_sub_column_id


2,初始化數(shù)據(jù)

import groovy.sql.Sql

//import groovyx.net.http.ContentType

log.info("-------------------------------------------------The Test Step start ---------------------------------------------")

/*            

*             1,獲取數(shù)據(jù)庫連接參數(shù),連接數(shù)據(jù)庫

*/

def tpProperties = testRunner.testCase.getProject()

def tsProperties = testRunner.testCase.getTestSuite()

def tcProperties = testRunner.getTestCase()


def service_ip= tpProperties.getPropertyValue( "YDGJ_IP" )

def refreshPath = tpProperties.getPropertyValue( "refreshPath" )

def db_url = tpProperties.getPropertyValue( "DB_Connection_URL" )

def db_user = tpProperties.getPropertyValue( "DB_loginname" )

def db_pwd = tpProperties.getPropertyValue( "DB_Password" )

def db_driver = tpProperties.getPropertyValue( "DB_Driver_Class" )


def sql = Sql.newInstance(db_url,db_user,db_pwd,db_driver)

     log.info("------ 1,獲取數(shù)據(jù)庫連接參數(shù),連接數(shù)據(jù)庫 finished")



     

/*            

*             2,初始化數(shù)據(jù)庫表

*/

// begin 初始化數(shù)據(jù)

def sqlStr = "call sp_easydata_genAll()"

log.info("自動(dòng)生成業(yè)務(wù)數(shù)據(jù) : " +  sqlStr)

sql.execute(sqlStr)


log.info("------ 2,初始化表基礎(chǔ)數(shù)據(jù) finished")


/*            

*             3,設(shè)置補(bǔ)充用例所需表數(shù)據(jù)

*/

 

/*

def sqlStr = "select first 1 from "

log.info(sqlStr)

sql.execute(sqlStr);

*/

log.info("------ 3,設(shè)置補(bǔ)充用例所需表數(shù)據(jù) finished, (請根據(jù)業(yè)務(wù)設(shè)置!)")


/*            

*             4,設(shè)置 或 從數(shù)據(jù)表獲取 用例參數(shù)值

*/

//設(shè)置數(shù)據(jù)-必填

def curTime = System.currentTimeMillis()

//log.info("curTime:" + curTime)

def shopName= "shopName"+curTime

log.info(shopName)

tcProperties.setPropertyValue( "shopName", shopName) 

tcProperties.setPropertyValue( "userId", "2916011") 

tcProperties.setPropertyValue( "shopkeeper","店主姓名呀") 

tcProperties.setPropertyValue( "provinceId","360000") 

3, 通過設(shè)置變量,獲取變量完成值傳遞


def tpProperties = testRunner.testCase.getProject()

def tsProperties = testRunner.testCase.getTestSuite()

def tcProperties = testRunner.getTestCase()


def shopName = tcProperties.getPropertyValue("shopName" )

def userId = tcProperties.getPropertyValue("userId" )

def shopkeeper = tcProperties.getPropertyValue("shopkeeper" )

def provinceId = tcProperties.getPropertyValue("provinceId" )




三,string 用split 處理成數(shù)組

log.info("skillsCertificateNos: " + skillsCertificateNos)

String[] strAry = skillsCertificateNos.split(",");

log.info ("strAry.size():" + strAry.size())

for (i=0;i<strAry.size();i++)

{

sqlStr = "select count(*) as cnt from 1dcq_p_w_upload  where file_no = '"+ strAry[i] + "'"

log.info(sqlStr)

sqlResult = sql.firstRow(sqlStr)

log.info ("skillsCertificateNos,,,,,,,,sqlResult.cnt : " + sqlResult.cnt)

assert sqlResult.cnt == 1

}



向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI